2012-09-02 4 views
0

여기에 약간의 문제가 있습니다. 특정 폴더 작업을 작동 시키려고 노력하고 있지만, 내가 무엇을 하든지 관계없이 작동시킬 수는 없습니다. 내 모든 다른 폴더 작업은 예상대로 작동합니다. 심지어 AppleScript를 사용했을 수도 있습니다. 그러나, 이것은 아닙니다. Heres는 '코드 :특정 폴더 작업을 가져올 수 없습니다.

on adding folder items to this_folder after receiving added_items 
--set added_items to choose file with multiple selections allowed 
processItems(added_items) 

end adding folder items to 

on processItems(added_items) 

set imageTypesList to {"JPEG image", "Portable Network Graphics image", "Windows bitmap image", "Graphics Interchange Format image", "Adobe Photoshop File", "TIFF Image"} 

set audioTypesList to {"MP3 audio", "AIFF-C audio", "Waveform audio"} 
set videoTypesList to {"Video-MPEG4", "MPEG-4 File", "Video-MPEG2", "Video-MPEG", "AVI", "Matroska Video File"} 
set fontTypesList to {"TrueType font", "PostScript® Type 1 outline font", "Font Suitcase"} 
set docsTypesList to {"Portable Document Format (PDF)", "Scrivener Project", "Microsoft Word 97 - 2004 document", "Rich Text Document", "Plain Text Document", "CSV Document", "Pages Publication", "Keynote Presentation"} 
set epubTypesList to {"epub", "Kindle Document", "iBooks Author Template", "iBooks Author Book"} 
set archTypesList to {"ZIP archive", "tar archive", "rar archive", "Tar Gzip Archive"} 
set diskTypesList to {"Installer package", "Disk Image"} 
set execTypesList to {"Unix Executable File"} 
set appsTypesList to {"Application (32-bit)", "Application"} 
set iconTypesList to {"Apple Icon Image", "Icon Container", "Windows Icon Image"} 
set otherTypesList to {"XTorrent File"} 
set scriptTypesList to {"Compiled OSA Script"} 
set openTypesList to {"Chromium Extra", "Action", "RapidWeaver Theme", "Mac OS X Preference Pane"} 

set uberList to imageTypesList & audioTypesList & videoTypesList & fontTypesList & docsTypesList & ¬ 
    epubTypesList & archTypesList & diskTypesList & execTypesList & appsTypesList & iconTypesList & ¬ 
    otherTypesList & scriptTypesList & openTypesList 

set imagesFolder to "Technomage:Users:andyhainline:Downloads:Images" as alias 
set appsFolder to "Technomage:Users:andyhainline:Downloads:Apps" as alias 
set archivesFolder to "Technomage:Users:andyhainline:Downloads:Archives" as alias 
set epubFolder to "Technomage:Users:andyhainline:Downloads:eBooks" as alias 
set fontsFolder to "Technomage:Users:andyhainline:Downloads:Fonts" as alias 
set docsFolder to "Technomage:Users:andyhainline:Downloads:PDFs and Docs" as alias 
set diskFolder to "Technomage:Users:andyhainline:Downloads:Installers and Disk Images" as alias 
set iconFolder to "Technomage:Users:andyhainline:Downloads:Icons" as alias 
set audioFolder to "Technomage:Users:andyhainline:Downloads:Audio" as alias 
set videoFolder to "Technomage:Users:andyhainline:Downloads:Video" as alias 
set otherFolder to "Technomage:Users:andyhainline:Downloads:Torrent Files" as alias 
set miscFolder to "Technomage:Users:andyhainline:Downloads:Miscellanious" as alias 
set scriptFolder to "Technomage:Users:andyhainline:Downloads:AppleScripts and Automator Stuff" as alias 
set execFolder to "Technomage:Users:andyhainline:Downloads:Run From Here" as alias 

tell application "Finder" 
    repeat with anItem in added_items 
     if (kind of anItem) is in imageTypesList then 
      move file anItem to imagesFolder with replacing 
     else if (kind of anItem) is in audioTypesList then 
      move file anItem to audioFolder with replacing 
     else if (kind of anItem) is in videoTypesList then 
      move file anItem to videoFolder with replacing 
     else if (kind of anItem) is in fontTypesList then 
      move file anItem to fontsFolder with replacing 
     else if (kind of anItem) is in docsTypesList then 
      move file anItem to docsFolder with replacing 
     else if (kind of anItem) is in epubTypesList then 
      move file anItem to epubFolder with replacing 
     else if (kind of anItem) is in archTypesList then 
      move file anItem to archivesFolder with replacing 
      open (path to archiveFolder & (name of file anItem)) 
     else if (kind of anItem) is in diskTypesList then 
      move file anItem to diskFolder with replacing 
     else if (kind of anItem) is in execTypesList then 
      move file anItem to appsFolder with replacing 
     else if (kind of anItem) is in webTypesList then 
      move file anItem to docsFolder with replacing 
     else if (kind of anItem) is in iconTypesList then 
      move file anItem to iconFolder with replacing 
     else if (kind of anItem) is in otherTypesList then 
      move file anItem to otherFolder with replacing 
     else if (kind of anItem) is in scriptTypes then 
      move file anItem to scriptFolder with replacing 
     else if (kind of anItem) is in openTypes then 
      delay 10 
      open anItem 
      move file anItem to miscFolder 
     else if (kind of anItem is "Folder") then 
      set folderFiles to get every file of folder anItem 
      processItems(folderFiles) 
     end if 
    end repeat 
end tell 

최종 processItems

당신이 볼 수 있듯이, 그것은 오히려 복잡하다. 참고 : 처음에 "on"핸들러를 주석 처리하고 "파일 선택"대화 상자로 스크립트를 실행하면 예상대로 완벽하게 작동합니다. 이론적으로 코드 자체에는 아무런 문제가 없습니다. 나는 "/ 라이브러리/스크립트/폴더 액션 스크립트"에서 파일 내 파일 사용 권한을 확인했습니다, 이것은 내가 무엇을 얻을 수 있습니다 : 나에게 정확히 잘 보이는

-rwxr-xr-x 1 root wheel 20758 Sep 2 14:43 add - copy based on type.scpt 

합니다. (파일을 저장 한 후에 이러한 사용 권한을 수동으로 설정해야했습니다.)

무슨 일이 벌어 지는지에 대한 아이디어가 있습니까?

--A.H.

답변

0

내 생각에 add_items가 파일 목록으로 예상되므로 반복 루프를 사용합니다. 아마 하나의 파일에 목록이 없으므로 반복 루프가 작동하지 않는다고 추측됩니다. 따라서 나는 added_items의 클래스를 확인하고 그에 따라 진행하는 것이 좋습니다. 그래서 스크립트의 맨 위 부분을 다음과 같이 변경하십시오.

on adding folder items to this_folder after receiving added_items 
    --set added_items to choose file with multiple selections allowed 
    if (class of added_items) is list then 
     processItems(added_items) 
    else 
     processItems({added_items}) -- here we make it a list so the repeat loop works 
    end if 
end adding folder items to 
관련 문제