2017-11-04 8 views
0

파일이 /resources/video.mov 인 폴더가 있습니다. 비디오가있는이 폴더는 /Users/UserName/Desktop/resources/video.mov 또는 /Applications/resources/video.mov 등 어떤 위치 에나있을 수 있습니다.이 폴더를 비디오로 찾아 특정 위치로 복사해야합니다. 복사 할 비디오가있는 폴더의 경로를 찾을 수 없습니다.특정 파일이있는 AppleScript 찾기 폴더

tell application "Finder" 
    duplicate items in folder "_locatedPath_" to folder "_destiontionPath_" with replacing 
end tell 
+0

의 출력 폴더에 변수 destinationFolder의 값을 사용하여 나를 위해 작동 'find' 또는'mdfind' 명령은 여러분의 친구입니다. 바닐라 AppleScript가 너무 느립니다. – vadian

답변

1

이것은 당신이 쉘의 위치를 ​​모르는 경우 시에라

의 최신 버전

변경 당신의 선택

property theContainer : missing value 
property containingFolder : "resources" -- change if needed 
property theSearch : "video.mov" -- change if needed 
property destinationFolder : (path to desktop as text) -- change if needed 

set findFile to do shell script "mdfind -name " & theSearch 

repeat with i from 1 to number of paragraphs in findFile 
    set this_item to POSIX file (paragraph i of findFile) as alias 
    tell application "Finder" 
     if name of this_item is theSearch then 
      set theContainer to the container of this_item as text 
      if theContainer contains containingFolder then 
       set resultObject to duplicate this_item ¬ 
        to destinationFolder ¬ 
        replacing true ¬ 
        routing suppressed true ¬ 
        with exact copy 
      end if 
     end if 
    end tell 
end repeat 
+0

OP가 "video.mov"또는 "video.mov"("리소스")의 포함 폴더의 모든 내용을 대상 폴더에만 복제하려고하는 경우 OP에 불투명합니다. 나는 OP가 "resources"폴더에있는 "video.mov"를 복제하려고하고 있다고 가정합니다. – wch1zpink

+0

고려해야 할 사항 : 스크립트 편집기에서 Finder 사전을 열고 POSIX를 검색하면 찾을 수 없습니다. 'Finder'는 실제로 this_item을 POSIX 파일의 this_item으로 설정할 수 없기 때문에 'tell it_item as POSIX file this_item as alias'를'tell application "Finder"_ _block_ 안에두면 안됩니다. 실제로'- -> POSIX 파일의 오류 번호 -1728. 그 블록 밖에 있어야합니다. 그러나, 당신은 또한'property fileList : {}'와'copy findFile to fileList'을 필요로하지 않습니다. 이 코드를 다시 보아라. (https://paste.ee/p/6IKdE) – user3439894

+0

'do shell script "에서 반환 된'fileList' mdfind -name"& theSearch'는 이미 POSIX 경로 이름의 단락이다. 'this_item을 POSIX 파일 this_item as alias'로 설정하고'this_item을 fileList의 단락 i로 설정 '을 변경하여 this_item을 POSIX 파일 (fileList의 단락 i)을 별칭으로 설정하십시오 .'. 또한'셸 스크립트를 사용하기 위해 fileList를 설정하십시오. "mdfind -name"& theSearch'는 Finder가 작동하도록 HFS + 경로에 다시 앨리어스하기 때문에 파일 이름을 공백으로 또는 공백으로 처리합니다. – user3439894