Batch file with latest date in file name

Dell /
November 18, 2009 at 12:54:39
Specs: Windows XP

If I wanted to create a batch file, which I could
run on a daily basis, and where the only
reliable run date is contained in the name of
the file, how could this happen?

ie. In a given folder, there are files created
daily with the date in it. For example:


These files are created daily, and ideally what
I'm looking at doing is creating a new file
called "DailyABCReport.xls" that will be over-
written each day with the latest report, and
scheduled to run and update automatically.

The new report would be copied as and saved


This file would be linked with a web-based


See More: Batch file with latest date in file name

Report •

November 18, 2009 at 13:56:22
Not quite with you on the linking, but this will get the copy done.

@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/o-d *-ABC.xls') do (
copy "%%a" C:\web\DailyABCReport.xls
goto :eof

Helping others achieve escape felicity


Report •

November 19, 2009 at 06:38:31
Mechanix2Go, thank you so much! This is wonderful!

Now supposing we had a folder created for each month?

For example:

Sep 09
Oct 09
Nov 09

And within the corresponding folder, they keep the most
updated spreadsheet, as in above?

Is there a way for this function to search all folders in the

Report •

November 20, 2009 at 04:56:37
So are you trying to get the latest file for each month?

Helping others achieve escape felicity


Report •

Related Solutions

December 1, 2009 at 05:56:43
Not from each month, but just the VERY latest file in the very
latest folder.

So for example:

If there is a folder that has the following folders:

Sep 09
Oct 09
Nov 09
Dec 09

And in each of these folders are daily excel files, I want it to
find the most recent file and the corresponding folder it
belongs to.

Report •

December 2, 2009 at 01:06:55
Run this and post a few lines of the output:

@echo off > newfile & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%a in ('dir/b *.xls') do (
echo %%~Ta %%a

Helping others achieve escape felicity


Report •

Ask Question