This will copy all .doc and.docx files from the current user's Documents folder to Documents\Backup
If the file name already exists, it adds a padded number to the end of the file name, MyFile0001.doc, MyFile0002.doc, etc. This way they will sort oldest to newest
It only copies new files, or files that have been changed since the last backup. It determines this based on the archive bit. If you run other backup programs, they may reset that bit when they make a backup; if so, this program would skip that version.
You can do it based on the modified date, but that gets a bit more complex.
Not sure if it will copy files that are open in Word, don't have Word on this system at the moment to test.
If you need help setting up a scheduled task, drop me a line. You can set it to run every day, or every 5 minutes for that matter.
Edit: Forgot to exclude the backups folder if it was a subfolder of the Source and found a couple typos, so copy/download again
Pastebin link - http://pastebin.com/gWg5x1Vt
@Echo Off
SetLocal EnableDelayedExpansion
:: Copies files from Source to Destination checking for duplicate names.
:: Filess with the same name will be given a padded, numbered, suffix
:: Uses the Archive bit to determine if a file should be copied.
Set _Source=%Userprofile%\Documents
Set _Dest=%Userprofile%\Documents\Backups
Set _Exts=*.doc *.docx
If Not Exist "%_Dest%" MD "%_Dest%"
:: copy files
PushD "%_Source%"
For /F "Delims=" %%I in ('Dir %_Exts% /A-DA /B /S 2^>Nul^|Findstr /I /V /C:"%_Dest%"') Do (
Call :_Dupcheck "%%~I"
Echo F|Xcopy "%%I" "%_Dest%\!_Newname!" /M /CHIRY>Nul
)
PopD
Goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Subroutines
:::::::::::::::::::::::::::::::::::::::::::::::::::::
:_DupCheck
Set _FN=%~n1
Set _FE=%~x1
Set _Count=0
Set _Extra=
Set _Newname=%_FN%%_FE%
:_Loop
If Exist "%_Dest%\%_FN%%_Extra%%_FE%" (
Set /A _Count+=1
Set _DupNum=0000!_Count!
Set _DupNum=!_DupNum:~-4!
Set _Extra=!_DupNum!
Goto _Loop
)
Set _Newname=%_FN%%_Extra%%_FE%