Place Time Stamp as a folder name


  1. Posts : 2
    Windows 7 Professional 32 bit
       #1

    Place Time Stamp as a folder name


    I create many new temporary folders every day. I am looking for a quick way to paste a time/date stamp for each new folder name. Wondering if there is a way I can link the time stamp to a windows hot key and use a paste rule?

    Don't want to use excel/word/cmd prompt and copy paste over to slow.

    Google turned up useless so I knew I could turn here for some assistance!

    Thank you.
      My Computer


  2. Posts : 1,781
    Windows 7 Professional SP1 32-bit
       #2

    You can use the %date% and %time% environment variables in a DOS prompt.

    Based on this, you could edit the registry to place an Explorer context menu shortcut to a command that creates a new folder in the current directory, along the lines of mkdir "Temp created on %date% at %time%".

    Unfortunately this won't be of much help - I just realized the date includes slashes "/" and the time uses colons ":", both of which are invalid characters in a file/folder name.
      My Computer


  3. Posts : 1,814
    XP / Win7 x64 Pro
       #3

    The following script will create a directory with the current timestamp (without the illegal characters):

    Code:
    @echo off
    For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
    For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
    
    set mydir="%mydate%_%mytime%"
    
    mkdir %mydir%
    Copy and paste that into something like "dirs.bat" and save it to your desktop. Then, with AHK, you could implement something like the following:

    Code:
    RAlt::Run C:\Documents and Settings\Username\Desktop\dirs.bat, C:\Documents and Settings\Username\Desktop
    However, it will create the directory wherever the bat file is run from, in this case the Desktop. If there is a certain directory you're always creating these temp folders in, you could easily change the code to reflect that directory and place the .bat file in there.
      My Computer


  4. Posts : 1,781
    Windows 7 Professional SP1 32-bit
       #4

    Awesome! That totally gets a rep from me. +1 :)
      My Computer


  5. Posts : 2
    Windows 7 Professional 32 bit
    Thread Starter
       #5

    Thanks friends. I will try to run a set up as described above. Thanks for the quick response as well!!
      My Computer


  6. Posts : 1,814
    XP / Win7 x64 Pro
       #6

    Just for further FYI with AHK, you can also run command line instructions directly from the script:

    Code:
    code = 
    (join& 
    date /t 
    time /t 
    ) 
    run %comspec% /k %code% 
    return
      My Computer


  7. Posts : 1
    Windows 7 Pro 64-bit
       #7

    As this was one of the top results for timestamps in Google, I'd thought I'd add a bit more.... Other options to use: Environment Variable Substrings: ie Extracts characters so 31/03/2012 = 12-03-31, and 14:59 = 1459 echo %date:~8,2%-%date:~3,2%-%date:~0,2% echo %time:~0,2%%time:~3,2% or another for loop format: for /f "tokens=1-3 delims=/" %%a in ('echo %date%') do @echo %%c%%b%%a or Time, w/o hundredths/sec: echo %time:~0,2%%time:~3,2% Environment Variable Substitution: ie Extracts characters so 31/03/2012 = 31032012, and 14:59 = 1459 echo %date:/=% Time, (with hundredths/sec) echo %TIME::=%
      My Computer


  8. Posts : 1
    64 win 7
       #8

    About 5 years ago, a friend of mine made a right-click context menu that did exactly this in XP. It was a real time saver! If anyone is thinking of making one, please let me know.
      My Computer


  9. Posts : 8
    Windows 7 Ultimate Version 6.1 (Build 7600)
       #9

    Ceezo said:
    About 5 years ago, a friend of mine made a right-click context menu that did exactly this in XP. It was a real time saver! If anyone is thinking of making one, please let me know.
    This is exactly what im looking for on Windows 10. If anyone has a solution, please do let me know. Thanks!
      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 15:33.
Find Us