Suggestion: Post-sync command conditioned on whether files were synced

Discuss new features and functions
Posts: 13
Joined: 9 Nov 2025

ravishahani

As far as I can tell, there is no easy way to tell from a post-sync command whether any files were synced. If there was nothing to sync, the sync operation is considered successful.

It would be great if there was a way to run a different command based on whether any files were synced, for example so I could not create a new archive of the synced files if no files were synced, since the archive contents would be identical.

If I am incorrect and there is a way to do this please let me know. As far as I understand the current implementation, I would need to find and parse the sync logfile to determine whether any files were synced.
Posts: 1222
Joined: 8 May 2006

therube

I don't know (?) if FFS sets %errorlevel%, but if it did... you might be able to check against that.


Pseudo-code:

grep -i "Items processed: 0 (0 bytes)" *.log > /dev/nul
if %errorlevel% == 0 goto nothinghappened
...

:nothinghappened
exit
Posts: 13
Joined: 9 Nov 2025

ravishahani

Thanks for the response, therube. That is a nice thought, but based on the documentation and my observation, there is no errorlevel associated with this condition. FreeFileSync.exe returns with errorlevel 0 as long as execution was successful, regardless of whether any files were copied or not.

From the online manual:
Exit Codes
0 Synchronization completed successfully
1 Synchronization completed with warnings
2 Synchronization completed with errors
3 Synchronization was aborted
Posts: 4910
Joined: 11 Jun 2019

xCSxXenon

You could parse the log file to obtain the number of items and base the actions off that
Posts: 13
Joined: 9 Nov 2025

ravishahani

Yes, parsing the log file has crossed my mind (and was suggested to me by Copilot). I would prefer not to do this since it is not a robust approach, e.g. I may not be aware of some corner cases in the log file format, or the format could change in a future release in a way that breaks my log processing code.
User avatar
Site Admin
Posts: 7523
Joined: 9 Dec 2007

Zenju

I've added scripting support for the next FFS version!
Write sync statistics to stdout as JSON for .ffs_batch

Instead of having only the exit code to work with, all the relevant sync statistics are returned for scripts to evaluate: https://freefilesync.org/manual.php?topic=scripting

FFS 14.6 Beta - Windows
FFS 14.6 Beta - Linux
Posts: 13
Joined: 9 Nov 2025

ravishahani

Thanks Zenju, that looks great!

Is it recommended to install the beta on top of the existing version, uninstall and install the beta, or install the beta in a different folder? I am running 14.5 donation version right now.
Posts: 13
Joined: 9 Nov 2025

ravishahani

I installed it in a separate folder for now in case I run into bugs and tried out the new scripting support. So far it seems to be working great! I will let you know if I find any bugs.

If I were to install this on top of the released 14.5 donation version would I retain the benefits of the donation version?
Posts: 4910
Joined: 11 Jun 2019

xCSxXenon

If I were to install this on top of the released 14.5 donation version would I retain the benefits of the donation version? ravishahani, 18 Nov 2025, 20:47
No, the donation edition files/flags/license is baked into your unique installer
Posts: 13
Joined: 9 Nov 2025

ravishahani

T'hanks, xCSxXenon.

I installed the beta in a different folder, but it seems to have broken the 14.5 donation version. I guess I will just use the beta version unless I run into a blocking issue.