Luis said:
Hello.
I'm trying to create a batch file that renames a certain zip file. The new
name should include the system date.
How can i this?
Thanks
Luis
ren c:\tempdir\myfilename.zip %date:~8,2%%date:~3,2%%date:~0,2%.zip
would rename c:\tempdir\myfilename.zip to c:\tempdir\050908.zip today (Sept.
08, 2005) PROVIDED your date format is dd/mm/yyyy.
There are methods to suit any date format you may be using. If you
ECHO %date%
at the prompt, this will show the date format you have selected. It may
contain dayname as well - and month,daynumber and year in a variety of
formats. If you post the format YOU have selected, the formula can be
customised.
The method is simple: %date:~m,n% is the n characters of the string,
starting at character m, where the FIRST character of the string is m=0
(C-style)
So, if your date format is
Thu 09-08-2005
and you want
20050908
then you use
%date:~10,4%%date:~4,2%%date:~7,2%
If you want to change the DIRECTORY (folder) that contains the file, then
you need to use the MOVE command, not REN.
move c:\tempdir\myfilename.zip
c:\where\I\want\it\to\be\%date:~10,4%%date:~4,2%%date:~7,2%.zip
(all on one line) will change the name AND move it to a different folder.
These commands could be either typed from the prompt or as a line in a batch
file.
Possible better newsgroups for batch methods: alt.msdos.batch.nt and
microsoft.public.win2000.cmdprompt.admin
HTH
....Bill