首先,我真的不知道AppleScript所以这可能是一个愚蠢的问题,但是......
我正在尝试用Photoshop操作指定文件夹中的所有文件(但由于脚本永远不会到达那个部分,我认为它不相关)。为了做到这一点,我只是复制了一个据称从Adobe's PS AppleScript Reference(第242-243页)做出我想要的或多或少的脚本。 (我将不得不进行一些更改,但从概念上讲,这正是我想要的。)但是脚本(从Adobe未经修改的剪切和粘贴)不起作用。问题似乎与这一行有关:
set fileList to (every file of anItem whose creator type is "8BIM") as alias list
“选择文件夹”返回的“anItem”是文件夹,“创建者类型”8BIM“是Photoshop
运行时,脚本会在该行死亡并出现此错误:
error "Can’t make every file of item 1 of
{alias \"Macintosh HD:Users:me:Desktop:PS Resave Test In:\"}
whose «class fcrt» = \"8BIM\" into type alias list." number -1700
from every file of item 1 of {alias "Macintosh HD:Users:me:Desktop:
PS Resave Test In:"} whose «class fcrt» = "8BIM" to «class alst»
我无法找到任何搜索AppleScript错误号-1700的内容。
任何人都可以告诉我发生了什么,所以我可以解决它吗?如果它有用,我可以发布其余的脚本,或者只看到以前的Adobe参考链接。
谢谢!
-----------------附录1 --------------------
下面adayzdone的回答解决了这个问题(谢谢!),但脚本现在在这一行失败了:repeat with aFile in fileList
tell application "Finder" to set fileName to name of aFile
出现此错误:
error "Finder got an error: Can’t get alias
\"Macintosh HD:Users:me:Desktop:PS Resave Test In:Image 1.tif\"."
number -1728 from alias
"Macintosh HD:Users:me:Desktop:PS Resave Test In:Image 1.tif"
再次,非常感谢任何帮助。
-----------------附录2 --------------------
根据要求,这是整个脚本:
-- Process all files in folders dropped on this script
-- (when saved as an applet)
-- Save each Adobe Photoshop CC file as a PDF file.
on run
tell me to open {choose folder}
end run
on open droppedItems
set destFolder to choose folder with prompt "Destination folder?"
repeat with anItem in droppedItems
tell application "Finder"
-- Make sure each item processed by this script is a folder
if class of item anItem is not folder then
-- Not a folder, notify the user of the error
display dialog "Please drop only folders on this script"
else
-- A folder, get the Adobe Photoshop CC files and process them
set fileList to (every file of folder anItem whose creator type is "8BIM") as alias list
end if
end tell
SaveFilesAsPDF(fileList, destFolder)
end repeat
end open
-- fileList is a list of aliases to Photoshop files
-- destFolder is an alias to a folder where the PDF files are to be saved
on SaveFilesAsPDF(fileList, destFolder)
set destPath to destFolder as string
repeat with aFile in fileList
tell application "Finder" to set fileName to name of aFile
set newFilePath to destPath & fileName & ".pdf"
tell application "Adobe Photoshop CC"
open aFile
save current document in file newFilePath as Photoshop PDF ¬
with options {class:PDF save options, PDF compatibility:PDF 15, preserve editing:true} ¬
close current document saving no
end tell
end repeat
end SaveFilesAsPDF
答案 0 :(得分:1)
尝试:
tell application "Finder" to set fileList to (every file of folder anItem whose creator type is "8BIM") as alias list
答案 1 :(得分:0)
我想我明白了。从你提供给我的第一个探测器的修复中推断,我在“aFile in”告诉应用程序“Finder”之前添加了'file',将fileName设置为aFile的名称,并且它有效。如果没有你的帮助我绝不会得到这个工作,如果你认为合适的话,请提出你可能对代码提出的任何其他建议。我会继续看。