copy and rename files with last date

June 21, 2012 at 22:45:38
Specs: Windows XP
I am new to batch scripting and wondering how can I rename files after coping them to a folder with a last date at the end of the filename.

Currently my batch file looks for all the PDFs which contain (ABCD) in their filename under a directory (C:\Folder1) and then copies them to a folder called (C:\Folder1\ABCD) which works fine:

pushd C:\Folder1

for %%a in (ABCD) do (

copy "*%%a*.PDF" "%%a"


The source directory (C:\Folder1) is updated every Friday and then after coping files to the ABCD folder using my batch file, the filenames should be followed by the date of every last Monday. Let say today is Friday (2012-06-22) and the date (2012-06-18) should be added at the end of each file.

Would be grateful if someone can help me.

See More: copy and rename files with last date

Report •

June 22, 2012 at 10:18:41
copy "*%%a*.PDF" "%%a%date%"

:: mike

Report •

June 22, 2012 at 11:53:50
Date math in batch is too much of a pain. You may want to consider a different language.


Report •

June 22, 2012 at 12:27:31
oops, just saw the date needed to be added

:: mike

Report •

Related Solutions

June 22, 2012 at 22:14:44
vb & vbscript has date(/time)math. Call if you want code to help.

Report •

June 23, 2012 at 01:49:32
Post the output of this:

echo %DATE%

Life is too important to be taken seriously.


Report •

June 23, 2012 at 07:43:43
Thanks for your comments. Seems there is not an easy way to achive it using a batch file. Decided to use C# instead. :)

Report •

Ask Question