Batch scripting

FreeFileSync can be called from command line and supports integration into batch scripts. This section gives some general hints and examples for Windows *.cmd and *.bat scripts.

When FreeFileSync is started in batch mode (a *.ffs_batch file is passed as argument) it returns one of the following status codes:

Return Codes
0 - Synchronization completed successfully
1 - Synchronization completed with warnings
2 - Synchronization completed with errors
3 - Synchronization was aborted



Now you can check if synchronization was successful from a script:

"C:\Program Files\FreeFileSync\FreeFileSync.exe" "H:\some folder\SyncJob.ffs_batch"
if errorlevel 1 (
  
::if return code is 1 or greater, something went wrong, add special treatment here
  
echo Errors occurred during synchronization...
  
pause
)



Instead of displaying "An error occurred!" you can also send an email notification (using a third party tool).


Attention
Make sure your script is not blocked by a popup dialog. Consider the following options when setting up a FreeFileSync batch job:

  • Disable checkbox Show progress dialog or have On completion automatically close the results dialog after synchronization.

  • Set error handling to Exit instantly or Ignore errors.