Renaming a number of files and moving files f

Microsoft Running ms-dos 20th anniversar...
March 9, 2010 at 08:04:06
Specs: Windows XP
Hi,
I have a task to basically rename files in a directory...so for example the file is a.txt, b.txt, c.txt...etc...and I want to rename each one to a-20100309.txt, b-20100309.txt etc...basically want to append a timestamp to the end of the file name, before the .txt extension. I dont know what the file names will be in the directory using a, b,c as examples, but I do know the extension will be .txt. I then need to be able to move the files to another directory.
Its years since I used dos scripts, and thats what I need to use, so any tips/hints would be brilliant
thanks!

See More: Renaming a number of files and moving files f

Report •


#1
March 9, 2010 at 08:33:45
@echo off

Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-4,4%
Set TodayDate=%Year%%Month%%Day%

for /f %%a in (dir /b) do (
  ren %%a %TodayDate%-%%a
)


Report •

#2
March 10, 2010 at 02:52:38
hi, getting an error msg - the system cannot find the file dir
any ideas what would be causing it?
thanks

Report •

#3
March 10, 2010 at 06:55:42
I for got the quotes around the DIR command...

@echo off

Set Day=%Date:~-7,2%
Set Month=%Date:~-10,2%
Set Year=%Date:~-4,4%
Set TodayDate=%Year%%Month%%Day%

for /f %%a in ('dir /b') do (
  ren %%a %TodayDate%-%%a
)


Report •

Related Solutions


Ask Question