Camillia
asked on
BAT file to change file name
This is probably not the right forum but I'm not sure where to put this...
I'm looking for a BAT file to look at a drive folder and change the file name by adding a timestamp at the end of the filename...
For example, I have c:\folder1\myfile.csv.
I want to change it to c:\folder1\myfile20110923. csv
Never done a BAT file!
I'm looking for a BAT file to look at a drive folder and change the file name by adding a timestamp at the end of the filename...
For example, I have c:\folder1\myfile.csv.
I want to change it to c:\folder1\myfile20110923.
Never done a BAT file!
What time are you wanting? A hard coded time? The current time? or the File attribute time?
ASKER
current time
http://www.intelliadmin.co m/index.ph p/2007/02/ create-a-d ate-and-ti me-stamp-i n-your-bat ch-files/
For a simple one liner use this:
For a simple one liner use this:
REN c:\folder1\myfile.csv c:\folder1\myfile%date:~-4,4%%date:~-7,2%%date:~-10,2%.csv
You can use patterns in the REN command (rename) as well. Put that line in a .bat file and you're good to go.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
My last post will walk a tree for you...just change the MyDir Variable to the top level...
ASKER
thank you. I will try
ASKER
going to try this now, thanks