Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, this is a simple question I am sure but I'm a novice when it comes to batch scripting and programming so I hope I can find the answers I seek here.

Machine Specifications

OS - Windows Server 2003 R2 Standard Edition Service Pack 2


CPU - Dual Core Xeon 2.67GHz

The situation

I have a server with a hard drive that I use for storing phone call recordings, it only has 350GB of space and is completely full so my recordings are no longer being stored until I clear it. These recordings have been piling up since 2011, so manually copying the files is nearly impossible since I don't have that much RAM and windows always times out and goes to not responding when I try.

What I need to do

I need a script that will take the files from before a certain date (IE. before 1/1/2013) and move them to a share on my NAS unit at \192.168.x.x\Recordings and once they are finished being copied to that share to delete the original files from the hard drive to free up that space.

I'm sure this is easy and probably a stupid question to ask here but I really need to get this done as it is crucial for our customers/employees.

Thank you in advance for helpful answers!!! Very much appreciated!

share|improve this question
We're not here to write scripts for you, just help when you get stuck or have specific questions. :) So, what have you got already? Where are you getting stuck? Have you gone over questions like Batch file to copy files from desktop location to another location? yet? – Ƭᴇcʜιᴇ007 Apr 3 '13 at 18:41
Well, I know how to do xcopy to copy files but what I don't know how to do is make it search the directory for files created before a specific date, if I knew how to do that then I'm sure it would be easy to put the pieces together. The other thing I don't know how to do is delete those files with the script after they have been copied over. I am Googling to find out how to do this also so I might not need the answer shortly :) – dan Apr 3 '13 at 18:42
So I basically need something to copy all files before a date. I know I can do 'xcopy from_location to_location /d:date' to copy the files created after a specific date, but what is the syntax for before a certain date? – dan Apr 3 '13 at 18:56
copy time & date dependent files with robocopy & forfiles. Delete them with forfiles too :) – Endoro Apr 3 '13 at 19:00
Dan, instead of updating your question you should answer your own question and accept it. – KronoS Apr 3 '13 at 21:58

If you download and install the Windows 2000 Resource Kit, it includes a command line utility called robocopy that can perform this task with one command.

Below is an example of how you would use robocopy for this:

robocopy.exe C:\from_location C:\to_locations *.* /MAXAGE:MaximumAgeOfFilesToCopy /MINAGE:MinimumAgeOfFilesToCopy

The below is from Robocopy's help (robocopy /?) that explains how the /MAXAGE and /MINAGE options work:

      /MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.
      /MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.
      /MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n.
      /MINLAD:n :: MINimum Last Access Date - exclude files used since n.
                   (If n < 1900 then n = n days, else n = YYYYMMDD date).
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.