此applet代码在单个选定文件夹内或单击applet时在Finder中打开文件夹时创建特定文件夹结构。如果选择了多个文件夹,则会中断。有没有办法让这个脚本在选择多个文件夹时工作?
property archivesFolder : "Archives"
property imagesFolder : "Images"
property proofreadFolder : "Proofreading"
property proofFolder : "Proofs"
property sourceFolder : "Source"
try
tell application "Finder" to set theLocation to the selection as alias
on error
tell application "Finder" to set theLocation to (folder of the front window as alias)
end try
tell application "Finder"
if not (exists folder archivesFolder of theLocation) then
make new folder at theLocation with properties {name:archivesFolder}
end if
if not (exists folder imagesFolder of theLocation) then
make new folder at theLocation with properties {name:imagesFolder}
end if
if not (exists folder proofreadFolder of theLocation) then
make new folder at theLocation with properties {name:proofreadFolder}
end if
if not (exists folder proofFolder of theLocation) then
make new folder at theLocation with properties {name:proofFolder}
end if
if not (exists folder sourceFolder of theLocation) then
make new folder at theLocation with properties {name:sourceFolder}
end if
end tell
答案 0 :(得分:2)
试试这个:
property folderNames : {"Archives", "Images", "Proofreading", "Proofs", "Source"}
tell application "Finder"
set selectedFolders to selection
if (count of selectedFolders) > 0 then
repeat with aFolder in selectedFolders
set theLocation to aFolder as string
repeat with newFolder in folderNames
try
make new folder at theLocation with properties {name:"" & newFolder & ""}
end try
end repeat
end repeat
else
set theLocation to (target of front window) as string
repeat with newFolder in folderNames
try
make new folder at theLocation with properties {name:"" & newFolder & ""}
end try
end repeat
end if
end tell