copy files with time-stamp specific.

I need to copy some log files from a log folder daily.  The time-stamp of the log files is from two days ago to the time of the copy.  

Please advise how to do it.  

DOS script is just fine.  

Thanks.
nav2567Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SubsunCommented:
If you are trying to copy the log files modified date older than 2 days..

Following PowerShell code will copy all two days old files from C:\logs to C:\Logcopy..
GCI C:\logs | ?{$_.LastWriteTime -lt (Get-Date).adddays(-2)} | Copy-Item -Destination C:\Logcopy

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewCommented:
Can you be a little more specific.

Do you want to copy all the files in the folder each day?

Where are the files going to?

Do you only want to copy a certain date or age of files?

How does the time stamp factor in, and is that inside the data of the file, or in the file name?

Etc...

~bp
0
footechCommented:
I think you mean anything newer than 2 days ago, in which case you would just need to change the "-lt" in Subsun's script to "-gt".  If you want to include any files created on that day (for example if the script is run on 9/12 at 11 a.m. and you want to include anything created on 9/10 or newer and not just newer than 9/10 11 a.m.), then we could modify it to be
GCI C:\logs | ?{$_.LastWriteTime -gt (Get-Date).adddays(-2).Date} | Copy-Item -Destination C:\Logcopy

Open in new window

Last question would be are you interested in the LastWriteTime or the CreationTime?
0
VeegertxCommented:
You said Dos ok. Use the Retry and wait in case they are open

@echo off
Robocopy "D:\Logs" "E:\Logs" /v /mir /R:2 /W:30
pause
mkdir c:\delete
robocopy "E:\Logs" c:\Delete /e /MOVE /MINAGE:3 /R:2 /W:30
pause
rmdir c:\delete /s /q
0
Michael DyerSenior Systems Support AnalystCommented:
Veegertx's solution looks good.  Robocopy, or "Robust File Copy", is a command-line directory replication command.  It has been available as part of the Windows Resource Kit starting with Windows NT 4.0, and was first introduced as a standard feature in Windows Vista and Windows Server 2008.

If you need a copy for Server 2003, you can get it here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.