ここで少し問題があります。特定のフォルダー アクションを動作させようとしていますが、何をしても動作しないようです。他のすべてのフォルダ アクションは、自分で AppleScript を実行したものも含め、期待どおりに機能します。しかし、これではありません。コードは次のとおりです。
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
end processItems
ご覧のとおり、かなり複雑です。注意: 最初の "on" ハンドラをコメントアウトし、"choose files" ダイアログでスクリプトを実行すると、期待どおりに完全に機能します。したがって、理論的には、コード自体に問題はありません。「/Library/Scripts/Folder Action Scripts」でファイルのアクセス許可を確認したところ、次のようになりました。
-rwxr-xr-x 1 root wheel 20758 Sep 2 14:43 add - copy based on type.scpt
私にはどちらが正しいように見えますか。(ファイルを保存した後、これらのアクセス許可を手動で設定する必要がありました。)
何がうまくいかないかについてのアイデアはありますか?
--ああ