|
Answer» I want to RENAME a folder to the folder name plus today's date. I have a general idea of how to do this but I can't get the syntax correct. example: gem.train changes to gem.train_today's dateCode: [Select]ren gem.train gem.train_%date% EDIT:
what you see when you type in cmd echo %date% ??echo %date% Tue 09/23/2008
batchfile.bat ren gem.train gem.train_Tue 09/23/2008 The syntax of the comand is incorrectshould work now Code: [Select]ren gem.train "gem.train_%date%"ren c:\gem.train "gem.train_%date%" The system cannot find the path specified.You need to strip the '/' characters out of the date first
Code: [Select]ren c:\gem.train "gem.train_%date:/=%" Its always handy to stick an ECHO in front of the command while you are trying it out, so you can see what it will be trying to do, then when the command line looks ok, remove the echo and away you go GrahamThat's it. Thanks allHi Grammie85. Glad to see you found a solution, & sorry I came to the party late. For further variety, try PLAYING around with the code below. (I modified it from code I found on the web). Cheers! (Of course, it assumes the necessary files & folders are in place already, and it renames the orginals WITHOUT further MODIFYING them).
Code: [Select]REM --> Renames a File or Folder with a TIMESTAMP. Keeps Folder Contents Intact. REM --------------------------------------- echo off set hh=%time:~0,2% if "%time:~0,1%"==" " set hh=0%hh:~1,1% set yyyy-mm-dd__hh.mm.ss=%date:~10,4%-%date:~4,2%-%date:~7,2%__%hh%.%time:~3,2%.%time:~6,2%---%date:~-0,3% set myDate01=%date:~10,4%-%date:~4,2%-%date:~7,2% set myDate02=%date:~10,4%-%date:~4,2%-%date:~7,2%__%hh%.%time:~3,2%.%time:~6,2% echo on
move tempZip.zip LogArchive%yyyy-mm-dd__hh.mm.ss%.zip move tempFile.txt tempFile%yyyy-mm-dd__hh.mm.ss%.txt move tempFolder tempFolder%yyyy-mm-dd__hh.mm.ss% move testFile01.txt testFile01%myDate01%.txt move testFile02.txt testFile02%myDate02%.txt
|