Batch script

Closed
milanese1 Posts 1 Registration date Monday December 14, 2009 Status Member Last seen December 15, 2009 - Dec 15, 2009 at 03:03 PM
 Hawk - Dec 23, 2009 at 09:34 AM
Hi,
I am very new when it comes to batch files and I need to copy some files from a directory to another on a windows 2003 server.
I have writeen a simple batch file which looks like this:

@echo off
SET Day=%date:~0,2%
SET Month=%date:~3,2%
SET Year=%date:~6,4%
SET cdate=%Year%%Month%%Day%

SET localDir=D:\New_Files
SET newDir=D:\test

COPY "D:\New_Files\*.dat" "D:\test\*.dat"

pause
rem dir c:\windows

This is all work, bt the problem I am having is that I only need to copy across files whose date is in the past, i.e.:
The list of files is this
a20091211.dat
a20091212.dat
b20091216.dat c20091214.dat c20091215.dat
e20091101.dat

Today is the 15th December 2009 and the file for today would like *20091215.dat. I need to copy all and only the files whose date is prior to today, so I should just move the below files:

a20091211.dat
a20091212.dat c20091214.dat
e20091101.dat

I have searched high and low on the web and could not find anything: can you please advise on a solution or anywhere where I can find a way to do it?
Thanks

1 response

I have some queries. If you clear that i might be able to help you,

1. Are u running this batch daily?
2. Are files generated on future dates ?
0