除了在添加文件夹项目句柄中运行对话框外,我无法运行其他任何操作。该代码不会通过if语句。任何帮助,将不胜感激。代码如下:
on adding folder items to theAttachedFolder after receiving theNewItems
set author to theNewItems
if "blah" is in author then
set theDialogText to "Blah in filename"
display dialog theDialogText buttons {"Continue", "Close"} default button "Close" with icon note
set author to ""
else if "lol" is in author then
set theDialogText to "Lol in file name"
display dialog theDialogText buttons {"Continue", "Close order"} default button "Close" with icon note
set author to ""
else if "ha" is in author then
set theDialogText to "Ha is in file name"
display dialog theDialogText buttons {"Continue", "Close"} default button "Close" with icon note
set author to ""
else if "omg" is in author then
set theDialogText to "omg is in file name"
display dialog theDialogText buttons {"Continue", "close"} default button "Close" with icon note
end if
end adding folder items to
答案 0 :(得分:0)
theNewItems
是alias
指定者的列表。将此类型与字符串进行比较总是失败。
您必须获取商品的名称,并且必须迭代文件列表
on adding folder items to theAttachedFolder after receiving theNewItems
repeat with anItem in theNewItems
tell application "System Events" to set fileName to name of anItem
if "blah" is in fileName then
set theDialogText to "Blah in filename"
display dialog theDialogText buttons {"Continue", "Close"} default button "Close" with icon note
else if "lol" is in fileName then
set theDialogText to "Lol in file name"
display dialog theDialogText buttons {"Continue", "Close order"} default button "Close" with icon note
else if "ha" is in fileName then
set theDialogText to "Ha is in file name"
display dialog theDialogText buttons {"Continue", "Close"} default button "Close" with icon note
else if "omg" is in fileName then
set theDialogText to "omg is in file name"
display dialog theDialogText buttons {"Continue", "close"} default button "Close" with icon note
end if
end repeat
end adding folder items to