Thursday, May 16, 2013

Backup local files to home share

For Windows 7, batch file to copy contents of users' Desktop and Documents to a home share.

robocopy "%USERPROFILE%\Desktop" "%HOMESHARE%\Desktop" /MIR /R:2 /W:3
robocopy "%USERPROFILE%\Documents" "%HOMESHARE%\Documents" /MIR /R:2 /W:3


For XP or where robocopy does not work.

rd /S /Q "%HOMESHARE%\Desktop"
rd /S /Q "%HOMESHARE%\Documents"
mkdir "%HOMESHARE%\Desktop"
mkdir "%HOMESHARE%\Documents"
xcopy "%USERPROFILE%\Desktop" "%HOMESHARE%\Desktop" /S /E /Y /C
xcopy "%USERPROFILE%\Documents" "%HOMESHARE%\Documents" /S /E /Y /C