Applescript 选择名称扩展
Applescript selection name extension
我遇到了 selection 的扩展名问题
当我 select 超过 2 种不同的文件类型时它不起作用
请帮助
property doc_list : {"pdf", "doc"}
property image_list : {"jpg", "png", "tif", "tiff", "gif"}
tell application "Finder"
set sel to (get selection)
repeat with AnItem in sel
end repeat
if sel = {} then
display alert ("nothing selected")
else if name extension of AnItem is in doc_list then
display alert ("this is doc files")
else if name extension of AnItem is in image_list then
display alert ("this is images files")
else if name extension of AnItem is in image_list & doc_list then
display alert ("this is images and doc files")
else if name extension of AnItem is not in image_list & doc_list then
display alert ("unknown file type")
end if
end tell
必须将 end repeat
行移动到 end tell
之前。
这是一个稍微改进的版本。第三个 else if
子句永远不会达到,第四个可以是 else
property doc_list : {"pdf", "doc"}
property image_list : {"jpg", "png", "tif", "tiff", "gif"}
tell application "Finder"
set sel to (get selection)
if sel = {} then
display alert ("nothing selected")
return
end if
repeat with AnItem in sel
set nameExtension to name extension of AnItem
if nameExtension is in doc_list then
display alert ("this is doc files")
else if nameExtension is in image_list then
display alert ("this is images files")
else
display alert ("unknown file type " & quote & nameExtension & quote)
end if
end repeat
end tell
我遇到了 selection 的扩展名问题 当我 select 超过 2 种不同的文件类型时它不起作用 请帮助
property doc_list : {"pdf", "doc"}
property image_list : {"jpg", "png", "tif", "tiff", "gif"}
tell application "Finder"
set sel to (get selection)
repeat with AnItem in sel
end repeat
if sel = {} then
display alert ("nothing selected")
else if name extension of AnItem is in doc_list then
display alert ("this is doc files")
else if name extension of AnItem is in image_list then
display alert ("this is images files")
else if name extension of AnItem is in image_list & doc_list then
display alert ("this is images and doc files")
else if name extension of AnItem is not in image_list & doc_list then
display alert ("unknown file type")
end if
end tell
必须将 end repeat
行移动到 end tell
之前。
这是一个稍微改进的版本。第三个 else if
子句永远不会达到,第四个可以是 else
property doc_list : {"pdf", "doc"}
property image_list : {"jpg", "png", "tif", "tiff", "gif"}
tell application "Finder"
set sel to (get selection)
if sel = {} then
display alert ("nothing selected")
return
end if
repeat with AnItem in sel
set nameExtension to name extension of AnItem
if nameExtension is in doc_list then
display alert ("this is doc files")
else if nameExtension is in image_list then
display alert ("this is images files")
else
display alert ("unknown file type " & quote & nameExtension & quote)
end if
end repeat
end tell