What is wrong with this batch? renaming files in directory

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
maclovin
Posts: 6
Joined: 21 Jan 2011 04:13

What is wrong with this batch? renaming files in directory

#1 Post by maclovin » 21 Jan 2011 04:18

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"

ChickenSoup
Posts: 79
Joined: 13 Dec 2010 10:32

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

#2 Post by ChickenSoup » 21 Jan 2011 07:42

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"

Post Reply