Im facing a problem with AppleScript/Rsync.
I try to copy various folders from various drives to one HDD. The following shows a part of the Apple script which is more or less always the same part of code:
tell application "Finder"
if (disk "MAC SSD X5" exists) then
do shell script "rsync -azvp '/Volumes/MAC SSD X5' '/Volumes/Backup/MAC SSD X5' --progress --partial --delete --backup --backup-dir='/Volumes/Backup/Gelöschte\ Dateien'"
end if
end tell
If I run this in Applescript it works. But uses rsync 2.6.9 which has less functions and less performance.
While if I run:
rsync -azvp '/Volumes/MAC\ SSD\ X5' '/Volumes/Backup/MAC\ SSD\ X5' --progress --partial --delete --backup --backup-dir='/Volumes/Backup/Gelöschte\ Dateien'
directly in the terminal it uses rsync Version 3.2.3 from another folder.
I tried to remove the former Version (2.6.9) of rsync but I didn't succeed.
Also I tried to add
--rsync-path=/usr/bin/local/rsync
in Applescript. But it still uses rsync 2.6.9. Also if I add the path of the rsync 2.6.9 in Terminal it will uses the new rsync (so the flag is not working either way).
Hope anyone can help me out with this issue.
Thanks in advance!
do shell script
command is a part of Standard Additions in AppleScript. not Finder and as such should not be wrapped within thetell application "Finder"
block as it actual throws a non-fatal error. Proper coding in this use case would be to use Finder to set a flag and a separate code block to act on the flag or usetell me to
ortell current application to
in front of thedo shell script
command.exists disk
returns a boolean, I'd use System Events, (because it's faster than Finder), to set a boolean flag, e.g.diskExists
by coding, e.g.,tell application "System Events" to set diskExists to (exists disk "MAC SSD X5")
. Now the value ofdiskExists
is either true or false, so then to conditionally execute thedo shell script
command, I'd code, e.g.,if diskExists then do shell script "..."
-- This way commands that are not a part of an application's AppleScript dictionary are not being wrapped within itstell
block.