How to show rsync progress using automator?

I am using an Automator script to rsync two folders.

The problems is I don't know how much time is remaining when I sync the (very large) folders.

I know I can use --progress in Terminal if I run everything through Terminal. But I like this script because it asks me which folders / volumes to sync ... it dumbs it down for me.


Does anyone know a solution to make --progress data visible if I keep this in Automator?


Thanks.

-Ken

Posted on Jan 29, 2016 1:26 PM

Reply
6 replies

Jan 29, 2016 2:01 PM in response to Ami and Ken

The standard/typical solution to this involves redirecting the output of the rsync command to a file, then have a separate process/thread watch the log file and parse the data.


By default, when you invoke a shell command, the rest of the AppleScript/Automator actions wait until that process finishes, so this allows the process to continue in the background while you work on displaying the data to the user.


Automator isn't my first choice, though - it's just too hard to get loops and branches working.

In AppleScript, here's a crude example that will show a theoretical progress counter via the Notification Manager


repeat with i from 1 to 10


display notification ((i * 10) as text) & "%" with title "My Progress"


delay 1

end repeat


The trick here is deciphering rsync's log to understand how it's progressing.

Jan 29, 2016 2:40 PM in response to Ami and Ken

The following assumes that you have downloaded Rsync Wrapper from this location, and it is in your search path. Credits to StefanK at MacScripter.


The script will provide a running progress meter with percentage in a window, as rync runs. When rsync has finished, a pop-up display of the copy statistics will be presented. I used the same AppleScript as StefanK posted in the above link. Rsync Wrapper works fine when tested on El Capitan 10.11.3. Hope it helps you.


After I unzipped Rsync Wrapper in my Downloads folder, I soft-linked it into my ~/bin directory by the same name. ~/bin is in my search path, and I could just use it in the AppleScript without path issues.


The underlying ideas for the AppleScript/Objective-C Rsync Wrapper came from this post.


Here is the AppleScript that I used to copy the contents of my Picture folder to another empty folder named POut.


set theSource to POSIX path of ((path to home folder) as text) & "Pictures:"

set theDest to POSIX path of ((path to home folder) as text) & "POut:"


tell application "Rsync Wrapper"

activate

set {exit code:exitCode, error message:errorMessage, items transferred:filesCopied, statistics:stats} to rsync from source theSource to destination theDest arguments {"-au", "--exclude=.DS_Store"}


end tell

if exitCode is not 0 then

display dialogerrorMessage

else

display dialogstats

end if

return

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to show rsync progress using automator?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.