Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Command Prompt - Batch file to move files base on create date

I have a folder that I've been archiving files.  This folder is getting large, so I need to archive anything that is more than 2 months old.  Is there a bat script that someone has that I can use to move files base on create date from Folder1 to Folder2?

Folder location is as followed:

Folder1:
\\nt-1\data\backup\Archive

Folder2:
\\nt-2\data\backup\ArchiveOldFiles

So I want a script that can look into the Archive folder and see files that has been created that's more than 2 months old.  Move those files to the folder ArchiveOldFiles.  Any examples or script someone can provide me?  This would be a bat file where I can schedule to run like once a month or something.
0
holemania
Asked:
holemania
  • 2
2 Solutions
 
GovvyCommented:
Use robocopy command with /MINAGE flag
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
robocopy \\nt-1\data\backup\Archive \\nt-2\data\backup\ArchiveOldFiles /minage:60 /move

Open in new window

0
 
holemaniaAuthor Commented:
Thanks guys.  I got it working from Govvy's advice.

robocopy \\nt-1\data\backup\archive \\nt-2\data\backup\ArchiveOldFile /move minage:60
0
 
holemaniaAuthor Commented:
Got it working with Govvy's suggestion.  Thanks for the example gerwinjansen.  I did similar to what you posted, but got it working before you post.  So to be fair, I give Govvy a little bit more points.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now