I need to create a script to copy only the files created today in Z:\ drive to AWS S3 using aws s3 cp command at a scheduler basis.
For example in Z:\, currently I have these files:
Filename Date Modified
BELSIZE.0.DB2.NODE0000.CATN0000.20160313090011.001 3/13/2016 9:00 AM
BELSIZE.0.DB2.NODE0000.CATN0000.20160314090015.001 3/14/2016 9:00 AM
BELSIZE.0.DB2.NODE0000.CATN0000.20160315090010.001 3/15/2016 9:00 AM
BELSIZE.0.DB2.NODE0000.CATN0000.20160315100012.001 3/15/2016 10:00 AM
I need to copy only the last 2 files dated 3/15/2016 to AWS S3.
What I have now is:
List the path + filename created today:
forfiles /P "Z:\" /s /m *.* /d +0 /c "cmd /c echo @pathCopy file to AWS S3:
aws s3 cp Z:\BELSIZE.0.DB2.NODE0000.CATN0000.20160315090010.001 s3://backup
I am thinking of getting 1) as a list, loop through 1) and execute 2). How can I do this?
I tried the below command. The file created today doesn't get copied to S3.
forfiles /P "Z:\" /s /m *.001 /d +0 /c "cmd /c aws s3 cp @path s3://backup"