Pre work
If the user folders are linked to OneDrive there may be a difference in how user folders are addressed in a command prompt or powershell. I haven’t had a chance to test it.
If you go into explorer and right click the Documents folder that looks like it’s under “This PC” and select properties, the window that pops up will give the directory of the folder.
To find the true location of the user’s folders open regedit and go to:
Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
There you will see a list that includes the true path of user’s folders.
To include the whole source folder in the destination you must include the source folder’s name in the destination. You must also, for some stupid reason, include a space after the source and destination names.
Following is an example of a batch file, or command lines
Backup
echo.
echo.
echo Be sure you have the correct source directory paths!
echo Right click on file explorer and select properties for each user folder
echo.
echo.
pause
echo off
set month=%DATE:~4,2%
set day=%DATE:~7,2%
set month=%DATE:~,2%
set day=%DATE:~3,2%
set year=%DATE:~-2%
set hour=%time:~0,2%
set min=%time:~3,2%
set sec=%time:~6,2%
set milsec=%time:~9,2%
echo on
set FolderDateTime=%month%%day%%year%-%hour%%min%%sec%
set BackupDestination=Z:\UserBackup\%computername%\%username%\%FolderDateTime%
set src1=Documents
set src2=Pictures
set src3=Downloads
set src4=Desktop
set src5=Music
set src6=Videos
robocopy "%homedrive%%homepath%\src1 " "%BackupDestination%\src1 " /MIR /COPY:DAT /DCOPY:T
robocopy "%homedrive%%homepath%\src2 " "%BackupDestination%\src2 " /MIR /COPY:DAT /DCOPY:T
robocopy "%homedrive%%homepath%\src3 " "%BackupDestination%\src3 " /MIR /COPY:DAT /DCOPY:T
robocopy "%homedrive%%homepath%\src4 " "%BackupDestination%\src4 " /MIR /COPY:DAT /DCOPY:T
robocopy "%homedrive%%homepath%\src5 " "%BackupDestination%\src5 " /MIR /COPY:DAT /DCOPY:T
robocopy "%homedrive%%homepath%\src6 " "%BackupDestination%\src6 " /MIR /COPY:DAT /DCOPY:T
echo.
echo.
echo Copy has completed
echo To open the destination directory continue
echo.
echo.
pause
start %homedrive%%homepath%
pause