Create a directory on startup with date i.e. 12-03-2012


  1. Posts : 26
    windows 7 64 Bit
       #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 Computer


  2. Posts : 26
    windows 7 64 Bit
    Thread Starter
       #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 Computer


  3. Posts : 6,330
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
       #3

    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 Computer


  4. Posts : 26
    windows 7 64 Bit
    Thread Starter
       #4

    thanks for that... I will try that later.
      My Computer


  5. Posts : 1,800
    Windows 7 Pro x64 SP1
       #5

    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 Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 05:17.
Find Us