Saved Bookmarks
| 1. |
Solve : multiple file remanes with suffix .bat? |
|
Answer» C:\test>a NOW i have tried using many thing but it just didn't work Didn't work how? While a few of the MEMBERS may be psychic, even fewer are detectives. Base on the information you provided, this may work. Notice the move does the rename all in one command. Code: [Select]@ECHO OFF FOR /F "tokens=2,3,4 delims=/ " %%A IN ('date /t') DO SET DATEVAR=%%B%%A%%C FOR /F "tokens=5,6,7 delims=:. " %%A IN ('ver ^| time') DO IF NOT "%%A" == " %1" SET DATETIMEVAR=%DATEVAR%_%%A%%B%%C echo %DATETIMEVAR% for /f "tokens=1-2 delims=." %%x in ('dir /b c:\test') do ( move c:\test\%%x.%%y c:\test1\%%x*_%DATETIMEVAR%.%%y ) Good luck. C:\test>a 24062008_145426 The filename, directory name, or volume label syntax is incorrect. what is wrong? NOTE is should move and rename only files with extension .sft the .bak files should ignored from the whole process. regards, nkrsticYou typed it in wrong. i did copy and pasteThe original post was edited 28 minutes after the first reply, rendering any continuity in this thread meaningless. For anybody trying to make SENSE of this thread, I wish you luck. Hi Ill try to explain one more time, maybe you or anyone can help thank! FOLDER C:\TEST\ MT210.sft MT200.sft MT300.sft MT2102008202030.bak MT2002008303020.bak MT3002008151515.bak I need to move only the .sft files ( not the .bak they are not to be touched) to another folder c:\test1 and add a date-time stamp at the end of the name in the following format; MT210_DDMMYYYY_HHMMSS.sft I have tried using the script posted earlier but it didn't work. Help anyone! reagards, nkrstic Sorry Sidewinder I am new to the forum, sorry for the confusion! nkrsticfor /f "tokens=1*" %%a in ('dir C:\tst\*.sft /b') do move C:\tst\%%a %%a_%date:~4,2%%date:~7,2%%date:~10,4%_%time:~0,2%%time:~3,2%%time:~6,2%.sftThanks but i got an error; The syntax of the command is incorrect.Your original script generated the the datetime variable correctly. The original reply had an typo and did not filter the sft files. This should fix you right up: Code: [Select]@ECHO OFF FOR /F "tokens=2,3,4 delims=/ " %%A IN ('date /t') DO SET DATEVAR=%%B%%A%%C FOR /F "tokens=5,6,7 delims=:. " %%A IN ('ver ^| time') DO IF NOT "%%A" == " %1" SET DATETIMEVAR=%DATEVAR%_%%A%%B%%C echo %DATETIMEVAR% for /f "tokens=1-2 delims=." %%x in ('dir /b c:\test\*.sft') do ( move c:\test\%%x.%%y c:\test1\%%x_%DATETIMEVAR%.%%y ) Thank you !!!! IT WORKS GREAT... GREAT FORUM |
|