Home > Back-end >  Batch File Unable To Compare Two String Variables
Batch File Unable To Compare Two String Variables

Time:01-11

The company I work at utilizes a batch file to backup user profiles. The script originally used robocopy, but now also uses xcopy in some cases. We run this script manually when re-imaging users to copy all of their files/folders, as well as some customizations, to their personal network drive. We then can access this information on their new laptop and run the script again to re-apply everything to their new machine.

We noticed over hundreds of uses that occasionally this script would just not backup either the user's Desktop or Documents files and/or folders. We cannot find a consistent variable that causes this hiccup in our script though, and I have been tasked with updating the batch script so that we can eliminate this issue.

My thought was to include a check of sorts into the program to ensure that everything was copied over, and if not to run the backup of that specific destination again. To do this I run the following lines to grab an image of the file size of that folder, and all of it's sub-folders:

set backupdesktopsize=.set secondline=.

@FOR /F "tokens=1 delims=^^" %%G IN ('dir "           
  • Related