我想在applescript滴中设置变量一次,但它会让我为每个文件设置变量
我写了一个applescript droplet,我想:我想在applescript滴中设置变量一次,但它会让我为每个文件设置变量,applescript,Applescript,我写了一个applescript droplet,我想: 将一个或多个图像拖到液滴上 出现3个显示对话框,询问“宽度”、“高度”、“格式” 使用返回的上述文本处理所有丢弃的图像 3个显示对话框 目前,每个图像都会出现3个显示对话框(例如,3个图像=9个对话框)。有没有办法只回答这些对话一次?这是我的剧本: on run display dialog "This is a droplet" end run on open draggedItems set tid to AppleScr
on run
display dialog "This is a droplet"
end run
on open draggedItems
set tid to AppleScript's text item delimiters
--ask for new width
set newWidth to text returned of (display dialog "New Width" default answer ¬
"45" buttons {"Continue…", "Cancel"} ¬
default button 1)
--ask for new height
set newHeight to text returned of (display dialog "New Height" default answer ¬
"45" buttons {"Continue…", "Cancel"} ¬
default button 1)
--ask for formatType
set newFormat to text returned of (display dialog "Image Format" default answer ¬
"jpg" buttons {"Continue…", "Cancel"} ¬
default button 1)
--repeat
repeat with i in draggedItems
set theFile to (i as alias)
set theFilePath to (the POSIX path of theFile)
set fullFileName to name of (info for theFile without size)
set AppleScript's text item delimiters to "."
set fileNameNoExtension to first text item of fullFileName
--set fileExtension to second text item of fullFileName
set AppleScript's text item delimiters to tid
do shell script ("/usr/local/bin/convert " & quoted form of theFilePath & " -resize " & newWidth & "x" & newHeight & "\\! ~/desktop/" & fileNameNoExtension & "." & newFormat)
end repeat
end open
如果您将4个文件放置在此液滴上,则打开的draggedItems上的
已经是一个重复循环
on open draggedItems
display dialog (draggedItems as text)
end open
您将得到4个不同的对话框
你可以这样做
property askingForNew : true
on open draggedItems
if askingForNew is true then
--display dialogs
set askingForNew to false
end if
display dialog (draggedItems as text)
end open
或者拖动水滴上的文件夹并浏览其文件()