Reputation: 2030
I'm trying to test if a file from on folder path, exists in a different folder using this script:
set middfilesECON211 to ("/Volumes/middfiles/Classes/Spring14/ECON0211B/HANDOUTS" as POSIX file)
set gDriveECON211 to ("/Users/paolob/Google Drive/Spring 2014/ECON 211/Handouts" as POSIX file)
tell application "Finder"
set foo to every file of folder middfilesECON211
repeat with i from 1 to (length of foo)
if not (exists (item i of foo) is in files of folder gDriveECON211) then
duplicate (item i of foo) to gDriveECON211
end if
end repeat
end tell
I've tried a bunch of variation in the if not (exists) ...
clause, but to no avail.
Upvotes: 1
Views: 429
Reputation: 27613
set dir1 to POSIX file "/tmp/a"
set dir2 to POSIX file "/tmp/b"
tell application "Finder"
repeat with f in (get items of folder dir1)
if not (exists file (name of f) of folder dir2) then
duplicate f to folder dir2 without replacing
end if
end repeat
end tell
You can also use cp -n
:
do shell script "cp -nR /tmp/a/ /tmp/b"
Or rsync --ignore-existing
:
do shell script "rsync -r --ignore-existing /tmp/a/ /tmp/b"
Upvotes: 1