Page 1 of 1

Run batch file only if there was a file synced

Posted: Mon Nov 11, 2013 10:04 am
by TheFonz
I am using BestSync 2014 and am loving it so far, just wondering if it's possible to have BestSync run a batch file ONLY if a file has needed to be synced. If no file was synced I do not want the batch file to run. If this is not entirely possible I would rather the batch file not process the steps if there was nothing synced.
I would love to see a check box similar to the batch file to run before synchronization that states: "Run the application only when there are files need to be synchronized after scanning"
Any ideas?

Re: Run batch file only if there was a file synced

Posted: Thu Nov 14, 2013 1:48 am
by TheFonz
I came up with my own solution, feel free to use it:
This will only report if there are files, including files inside sub-folders - it will not count empty folders as a file and will return a result of empty

@echo off

goto :main

REM *** === Function "Test" ===================================================

:test
if not "%1" == "" (
if exist "%1" (
( dir /s /b /a-d "%1" | findstr "^" ) > nul && (
echo %1 not empty
) || (
echo %1 empty
)
) else (
echo %1 missing
)
) else (
echo error: no parameter
)
goto :EOF

REM *** === Main ==============================================================

:main

call :test "DownloadDirectoryHere"