I got this question via e-mail and decided I would post the answer here in a blog. (Updated 16th Feb 2017 with a typo correction)
I want transfer all files created in Office Word 2003 by year (annual batchs - ex: 2005, 2006, etc.) to external HD. How can to do this?
I will appreciate your answer.
To do this via the command line you can use Robocopy which is present in Windows Vista and Windows 7. If you have Windows XP download the Server 2003 Resource Toolkit and install it. Robocopy will be part of the install and found in the install directory.
The actual command would look like this and would need to be entered into a command prompt:
for /L %x in (2009,-1,2000) do robocopy source destination\%x *.doc? /maxage:%x0101 /minage:%x1231 /s
To break it down a bit..
- for /L %x in (2009,-1,2000) do
This creates a counter from 2009 up in steps of -1 (or down in steps of 1) until 2000 is reached. Each time the counter changes it is set into %x, so %x will become 2009, 2008 and so on. It then executes the command after to "do".
- robocopy source destination\%x *.doc? /minage:%x0101 /maxage:%x1231 /s
The robocopy command is very flexible. Details of it can be found on the wiki page here.
- The first two parameters are the sounce and destination locations. so it might be c:\users\david\documents and F:\document_backup. Note the \%x on the end. This means it will put the files inside a folder on the destination location that matches the year you are archiving.
- *.doc? is a limiter to the files to be copied - if you want all files, simply remove it. This will copy all Office 2003 and 2007 document files - if you only want Office 2003, use *.doc and don't include the question mark.
- The minage and maxage state how old the file is. It can either be in days or a date in the form of yyyymmdd. So with the %x set to 2009, the command will have /minage:20090101 /maxage:20091231 which equates to everything in 2009 and so on.
- The /s copies all subdirectories too
- You can optionally put the /MOV (to move the files) or /MOVE (to move all files and empty directories) command on the end.
I hope that helps
Wed, May 6 2009 11:26 AM
Filed under: Office System, Microsoft, Windows Client, Windows XP, Office 2007, Word, Tips, Office 2003, Windows 7, Windows Vista and XP, Windows Vista, Vista and XP