| Windows 7: Create a directory on startup with date i.e. 12-03-2012 |
12 Mar 2012
|
#1 | | |
Create a directory on startup with date i.e. 12-03-2012 Hi there,
I would like to create a daily folder on system startup which has the date like this 12-03-2012
I also want it to go to a certain place on my hard drive C:Users/Name/My Documents
I have this script but it puts the date the wrong way around and I would prefer dashes in between the dates?
for /f "skip=1" %%d in ('wmic os get localdatetime') do if not defined mydate set mydate=%%d
md %mydate:~0,8%
Thanks in advance, Jay ;-) | My System Specs |
| |
12 Mar 2012
|
#2 | | |
Ok slightly different way of doing this, now get the dashes between the dates
SET dd=%DATE:~0,2%-
SET mm=%DATE:~3,2%-
SET yyyy=%DATE:~6,4%
mkdir %dd%%mm%%yyyy%
How do I set the path for it create the dated folder? do I just add the path after mkdir?
i.e. C:Users\Name\My Documents
? | My System Specs | | |
12 Mar 2012
|
#3 | | Win 7 Pro x64 SP1, Win 7 Ult x86 SP1 NC, USA |
you can probably add the path to the filename as you thought.
mkdir C:Users\<Name>\Documents\%dd%%mm%%yyyy%
Or you can put this line in before the mkdir to set the path. (cd = change directory)
cd C:Users\<Name>\Documents
note: i think you need to use "Documents" (not "My Documents") in Win 7
<Name> would be your user name... | My System Specs | | Computer type PC/Desktop System Manufacturer/Model Number home built OS Win 7 Pro x64 SP1, Win 7 Ult x86 SP1 CPU AMD Athlon II x4 620 Motherboard Gigabyte GA-MA785G-UD3H Memory 6GB GSkill DDR2 800 Graphics Card AMD 4670 GPU + AMD 4200 IGP Sound Card on board Realtek ALC889A Monitor(s) Displays RCA 40" LCD TV, Insignia 32" LCD TV, HP 15" LCD monitor Screen Resolution 1680 x 1050... Keyboard Gyration wireless, Logitech wireless, Dell USB wired Mouse Gyration wireless, Logitech wireless, V7 USB wired PSU Corsair 500 W Case Rosewill mid tower Cooling CM 90mm Tower Hard Drives OCZ Vertex 3 120GB,
Samsung F3 1TB (3),
Several others - WD, Seagate, Hitachi, ... Internet Speed Uverse - 12Mbps D / 1.5Mbps U Antivirus Avast free OR MSE. (+ MBAM Pro). Browser 1-Firefox, 2-IE. (Chrome and Opera for testing) Other Info 2 PCs: Primary: dual-boot, Test: triple-boot.
Mainly HTPC/Gen purpose (no gaming).
Trendnet USB KVM.
LG DVD burner/Blue Ray Player.
Tray system for removable SATA backup drives.
Not currently OCd, under-volted.
I use Hybrid sleep, rarely re-boot or shutdown.
Hauppauge HD-PVR, Avermedia PCIe TV Tuner, Hauppauge PCI TV Tuner. |
13 Mar 2012
|
#5 | | Windows 7 Pro x64 SP1 Rockville, Maryland USA |
Jay76,
I I have done this in a simpler step.
give this a shot. But remember if you run it twice, it is setup to let you know it already exists.
copy the following:
rem this will create a directory in your documents directory
set DATEST=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%
echo %datest%
if exist %homepath%\documents\%datest% goto already
md %homepath%\documents\%datest%
pause
goto end1
:already
rem you already have created the directory %datest% in your %homepath%
:end1 | My System Specs | | Computer type Laptop System Manufacturer/Model Number Toshiba Laptop Qosimo X870 OS Windows 7 Pro x64 SP1 CPU Intel Core I7 Motherboard Toshiba Memory 16 Gigs Graphics Card NVIDIA GeForce GTX 670M Monitor(s) Displays 17.7" laptop Screen Resolution 1600 x 900 Hard Drives 256 Gig SanDisk SSD for C
256 Gig Intel SSD for D Internet Speed 50/25 FIOS Antivirus Vipre (all you can eat for 10 machines) Browser IE and FF Other Info I have dos 6.22, wfwg 3.11, win98, 2000 and xp VHD's available for testing. MS's Virtual PC works great. Create a directory on startup with date i.e. 12-03-2012 problems? All times are GMT -5. The time now is 03:02 PM. | |