Just a sample of the Echomail archive
Cooperative anarchy at its finest, still active today. Darkrealms is the Zone 1 Hub.
|    BATPOWER    |    Batch Language Programming    |    216 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 159 of 216    |
|    mark lewis to Bill Gordon    |
|    Renaming files to a date    |
|    03 Sep 15 16:20:48    |
      03 Sep 15 08:26, you wrote to All:               BG> At one time, I was able to write a batch file that would rename any file       to        BG> the present date.               BG> For example, it was possible to rename info.txt to 090315.txt. I have long        BG> since forgotten how to do this.               BG> Could someone refresh my memory? I'm using Windows XP SP3 on the       particular        BG> machine that I need to do this on.              do you have powershell on that box? i don't know if it is needed for this or       not, though...              anyway, here's a neat winwhatever script that can do the date and time       thing... currently it outputs YYYYMMDDhhmmss format... this is all native       winwhatever and uses no external 3rd party schtuffings...              just run it to see the output... the main key is the bottom ":mygettime"       section which must be as written the first line after the label is pretty long       and the second line starts with the "rem" statement... the output, as the file       currently is, should be something like              [quote]       -------------------       20150903173045       20150903173045 set blerg=x:\foo\bar       20150903173046 terminating       [/quote]              so in your script that needs to rename files, you would include the entire       ":mygettime" section and then in your script whereever you need the current       datetime stamp, you would              call :mygettime       ren somefile.txt %ldt%.txt              any time you need or want the datetime stamp, you "call :mygettime: first and       then use "%ldt%" for the stamp where ever you want it...              ==== Begin "LDT.BAT" ====       @echo off       Echo -------------------       call :mygettime       Echo %ldt%       set blerg=x:\foo\bar       call :mygettime       echo %ldt% set blerg=%blerg%                     :end       call :mygettime       echo %ldt% %0 terminating       echo.       if not '%blerg%' == '' set blerg=       goto :EOF              :mygettime       for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime       /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j       rem set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2% %ldt:~8,2%:%ldt:~10,2%:%ldt:~12,2%       set ldt=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2%%ldt:~8,2%%ldt:~10,2%%ldt:~12,2%       exit /b       ==== End "LDT.BAT" ====              )\/(ark              ... Cats have the simplest of taste - the best will suffice       ---        * Origin: (1:3634/12.73)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca