Re: rename file in batch with date in file name



I'm using windows 2000.I get emailed a file every day, say called "Daily

I want to save this file, from a directory, to another by clicking on a
batch file. The problem is that the file is called the same thing every day.
I want rename the file to (lets say) "20030916 daily file.xls" [today's date
in yyyymmdd format then the file name]

Can this be done? How would I modify the following:

copy d:\temp\daily file.xls c:\daily\?????????????

I'm also guessing that I cant use long filenames in DOS.Does this mean that
the file naming won't work?

The .Mount/\Command ".GetLogDate" will CONSISTENTLY display the date as
"yyyymmdd" under NT/2K/XP/K3 regardless of the local date format using no
external utilities. The value is also saved to variable "#LogDate".

In your specific case, the syntax would be:

copy "d:\temp\daily file.xls" "c:\daily\%#LogDate% daily file.xls"


For a color-keyed example, see


1. .Mount/\Commands are constructed using ONLY builtin
commands common to all four platforms (NT/2K/XP/K3).
2. .M/\C's are NOT case sensitive. Mixed case is used
for Visual Clarity only.


TheGuardBook contains a "Mounted Help" page for each internal cmd.exe
command. This is a single color-coded page, highlighting the differences
among the NT/2K/XP/K3 versions. The complete help text for each OS is also
available for comparison (


____________________________________________________________ | |
Free and "Almost Free" Knowledge for Windows System Admins!

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question