Batch file to rename a file to ddmmyy.txt

nortyrich

Beta member
Messages
2
I am trying to write a batch file that will be scheduled to run once daily in order to rename a constantly growing datafile to ddmmyy.txt. I would like to use the DOS system DATE variable but need to know how to manipulate the string from dd/mm/yyyy format to ddmmyy. Is there an easy way of doing this or can somebody point me in the right direction?
 
id be use python or perl |: simply because i dont know how to do it in dos
 
I've managed to solve this now, just by using the same syntax as described in the SET command help as follows

@Echo off
SET dd=%date:~0,2%
SET mm=%date:~3,2%
SET yy=%date:~8,2%
SET ndate=%dd%%mm%%yy%

REN c:\datafile.txt "l"%ndate%".txt
 
Back
Top Bottom