-
All replies
-
Helpful answers
-
-
Jan 29, 2016 2:01 PM in response to Ami and Kenby Camelot,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 Managerrepeat 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 Kenby VikingOSX,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 dialog errorMessage
else
display dialog stats
end if
return
-
Jan 29, 2016 3:23 PM in response to VikingOSXby VikingOSX,As an addendum, one can copy the Rsync Wrapper package into /Applications too. It has its own scripting dictionary, and will show up in the Script Editor's dictionary list of applications.
