2014-02-25 3 views
1

내가 폴더 경로에있는 파일이,이 스크립트를 사용하여 다른 폴더에있는 경우 테스트하기 위해 노력하고있어 중복되지 않는 폴더에있는 경우 :은 AppleScript를 파일

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 

나는 무리를 시도했습니다 if not (exists) ... 절의 변형이 있지만 아무 소용이 없습니다.

도움이 될 것입니다. 감사!

+0

http://stackoverflow.com/search?q=[applescript]duplicate+files –

답변

1
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 

당신은 또한 사용할 수 있습니다 cp -n :

do shell script "cp -nR /tmp/a/ /tmp/b" 

또는 rsync --ignore-existing :

do shell script "rsync -r --ignore-existing /tmp/a/ /tmp/b" 
+1

+1 그러나'man cp'가'-r'에 대해 말하는 것에 대해 걱정해야합니까? 'cp 유틸리티의 역사 버전에는 -r 옵션이 있습니다. 이 구현 은 해당 옵션을 지원합니다. 그러나 특수 파일, 심볼릭 링크 또는 FIFO를 올바르게 복사하지 않으므로 사용하지 않는 것이 좋습니다 .' – mklement0

관련 문제