Dos Batch File script to run datewise backup

Hello Experts,

I have a security camera server in which recordings are saved every hourly and daywise.

My requirement is to keep the data of 1 week in the server and rest of the saved files i want to transfer it to external HDD. I need a script which will check the date of the files created and if the date is greater then 7 days, it will copy those files to backup and delete from the server disc.
Hiren LapsiwalaManager - Information TechnologyAsked:
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.

oBdACommented:
No need for a script: just use robocopy (part of the OS since Vista/W2k8, part of the Resource Kit for XP/W2k3, http://www.microsoft.com/en-us/download/details.aspx?id=17657):
robocopy.exe "C:\Recordings" "R:\Backup\Recordings" *.* /minage:7 /mov

Open in new window

The first argument is the source folder(!), the second argument the target folder(!), then the file(s) and/or file masks to copy. /minage:7 copies only files that are older than 7 days, and /mov moves (deletes after the copy) the source files copied, but not the folders.
Enter "robocopy /?" for a list of other options that might be useful for you.
0
asterisqueCommented:
Try this :

set folder="c:\folder"
set days=7
forfiles -p %folder% -s -m *.* -d -%days% -c "cmd /c del @FILE"
0
oBdACommented:
One addition to robocopy in http:#a39561459: the current command line will only copy files directly in the source folder ("C:\Recordings"); if the files are organized in a subfolder structure, you need to add /s to the options to process subdirectories as well.
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
Hiren LapsiwalaManager - Information TechnologyAuthor Commented:
Thanks and it is working fine..
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 Legacy OS

From novice to tech pro — start learning today.