对AppleScript中文件夹中的所有文件执行操作

对AppleScript中文件夹中的所有文件执行操作,applescript,Applescript,首先,我真的不知道AppleScript,所以这可能是一个愚蠢的问题,但 我正试图用Photoshop处理指定文件夹中的所有文件(但由于脚本从未涉及到这一部分,我认为这与此无关)。为了做到这一点,我只是复制了一个脚本,据称它或多或少做了我想要的(第242-243页)。(我将不得不做一些更改,但从概念上讲,这正是我想要的。)但脚本(未经Adobe修改的剪切和粘贴)不起作用。问题似乎出在这一行上: set fileList to (every file of anItem whose creator

首先,我真的不知道AppleScript,所以这可能是一个愚蠢的问题,但

我正试图用Photoshop处理指定文件夹中的所有文件(但由于脚本从未涉及到这一部分,我认为这与此无关)。为了做到这一点,我只是复制了一个脚本,据称它或多或少做了我想要的(第242-243页)。(我将不得不做一些更改,但从概念上讲,这正是我想要的。)但脚本(未经Adobe修改的剪切和粘贴)不起作用。问题似乎出在这一行上:

set fileList to (every file of anItem whose creator type is "8BIM") as alias list
repeat with aFile in fileList
    tell application "Finder" to set fileName to name of aFile
其中“选择文件夹”返回的“anItem”是文件夹,“creator type”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»
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"
我在搜索AppleScript错误号-1700时找不到任何东西

有人能告诉我发生了什么,这样我就可以修复它吗?如果有帮助的话,我可以发布脚本的其余部分,或者只是查看Adobe参考的上一个链接

谢谢

-----------------增编1--------------------

下面adayzdone的回答修复了这个问题(谢谢!),但是脚本现在在这行失败了:

set fileList to (every file of anItem whose creator type is "8BIM") as alias list
repeat with aFile in fileList
    tell application "Finder" to set fileName to name of aFile
出现此错误时:

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»
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
尝试:


我想我明白了。根据您为我的第一个问题提供的修复,我在“告诉应用程序”查找程序中的“文件”之前添加了“文件”“将文件名设置为文件名”并成功。如果没有你的帮助,我永远不会让它工作。无论如何,如果你认为合适的话,请给出关于代码的任何其他建议。我会继续关注。

谢谢,这解决了这个问题,但现在脚本在那一行之后有点失败(你为什么对我这样做?)。关于代码和错误消息,请参见上面的原始问题(我无法找到任何方法将代码和错误放入注释中,因此,如果我通过编辑问题出错,对不起,请更正我)。完整的代码发布在原始问题中。这是您建议的更改,但是从Adobe剪切和粘贴的。