Page 1 of 1

What is wrong with this batch? renaming files in directory

Posted: 21 Jan 2011 04:18
by maclovin
Hello there!

Nice forum!

Can anyone tell me what is wrong with my batch-script?

I am trying to iterate through a directory renaming all files in it. Hopefully it will append time/date to all the files in that directory.

I am not sure I want to have a new fileending (.kvi), so if someone can guide me into what is wrong, and how I can avoid giving it a new file ending would be nice.

FOR %%T in (%tmpDir%*.*) DO RENAME "%%T"
"%%~nT_%date:~10,4%_%date:~4,2%_%date:~7,2%_%.kvi"

Re: What is wrong with this batch? renaming files in directo

Posted: 21 Jan 2011 07:42
by ChickenSoup
Is that actually on 2 lines? or did it just split like that on the page? The one liner should work as long as %tmpDir% has a ending "\" (that is set tmpDir=C:\temp\)

Code: Select all

set tmpDir=C:\temp\
FOR %%T in (%tmpDir%*.*) DO rename "%%T" "%~nT_%date:~10,4%_%date:~4,2%_%date:~7,2%_.kvi"