Can';无法在applescript工作流结束时获得正确的重复

Can';无法在applescript工作流结束时获得正确的重复,applescript,Applescript,我试图让Illustrator根据脚本末尾的原始文件名保存所有打开的文档。它会先保存哪个文件,但我不知道如何将其循环回以重新命名其余的文件。这些文件是以数字命名的,因此有时后面会保存前面的文件 -- get JobName set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job_Name") -- setup folder paths set loc to pat

我试图让Illustrator根据脚本末尾的原始文件名保存所有打开的文档。它会先保存哪个文件,但我不知道如何将其循环回以重新命名其余的文件。这些文件是以数字命名的,因此有时后面会保存前面的文件

 -- get JobName
set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job_Name")

-- setup folder paths
set loc to path to desktop as text
set downloadsFolder to path to downloads folder as text
set newfo to loc & JobName & ":"
set newfoSeps to newfo & JobName & "_Seps" & ":"

-- make sure all of the folders exist
tell application "Finder"
if not (exists folder newfo) then
    make new folder at loc with properties {name:JobName}
end if

if not (exists folder newfoSeps) then
    make new folder at folder newfo with properties {name:JobName & "_Seps"}
end if

end tell

set the clipboard to JobName -- this is not a Finder command so we do not put it in the Finder block of code

-- move files to newfo and get a list of them
tell application "Finder"
open folder newfo
move (files of folder downloadsFolder) to folder newfo
set newfoFiles to (files of folder newfo) as alias list
set bounds of front window to {1648, 268, 2418, 706}
end tell

-- open each file in Illustrator and make spot colors
repeat with aFile in newfoFiles
tell application "Adobe Illustrator"
    activate
    open aFile
    set WindowList to name of documents --List of every open documents name repeat with CurrentWindow in WindowList 
    set theName to name of current document
    set theNamecount to count of theName
    set theOutdatedPathObj to the file path of current document
    set thePath to (POSIX path of theOutdatedPathObj) as string
    set pathCount to count of thePath
    set pathCount to (pathCount - theNamecount)
    set newPath to (text 1 thru pathCount of thePath)

    tell document 1

        set docColorSpace to color space
        if (docColorSpace is CMYK) then
            set SpotColor1 to {cyan:21.0, magenta:0, yellow:100.0, black:0.0}
            set SpotColor2 to {cyan:11.0, magenta:100, yellow:30.0, black:0.0}
            set SpotColor3 to {cyan:0.0, magenta:0, yellow:0.0, black:100.0}

        else
            set SpotColor1 to {red:206.0, green:219.0, blue:41.0}
            set SpotColor2 to {red:215.0, green:23.0, blue:111.0}
            set SpotColor3 to {red:35.0, green:34.0, blue:33.0}
        end if

        make new spot with properties {name:"Highlight White", color type:spot color, color:SpotColor1}
        make new spot with properties {name:"Under Base", color type:spot color, color:SpotColor2}
        make new spot with properties {name:"Spot Black", color type:spot color, color:SpotColor3}
    end tell
    try
        if theName contains "back" then set newName to JobName & "_FB"

        if theName contains "front" then set newName to JobName & "_FF"

        set finalPath to newPath & newName
        (save current document in file finalPath as Illustrator) -- make sure finalPath looks like this (... folder:folder:Filename.ai) Name extension is important

    end try

end tell

end repeat

end

非常感谢你对蒂姆·乔的帮助

我将执行以下操作(可能需要稍微调整):

快速浏览了一下,没有在最终路径变量中看到扩展。保存后看到激活也有点奇怪

更新4/23

这是你的循环,没有时间调试

tell application "Adobe Illustrator"
    activate
    set WindowList to name of documents --List of every open documents name
    repeat with CurrentWindow in WindowList
        open aFile
set theName to name of current document
    set theNamecount to count of theName
    set theOutdatedPathObj to the file path of current document
    set thePath to (POSIX path of theOutdatedPathObj) as string
    set pathCount to count of thePath
    set pathCount to (pathCount - theNamecount)
    set newPath to (text 1 thru pathCount of thePath)
    tell document 1
        set docColorSpace to color space
        if (docColorSpace is CMYK) then
            set SpotColor1 to {cyan:21.0, magenta:0, yellow:100.0, black:0.0}
            set SpotColor2 to {cyan:11.0, magenta:100, yellow:30.0, black:0.0}
            set SpotColor3 to {cyan:0.0, magenta:0, yellow:0.0, black:100.0}
        else
            set SpotColor1 to {red:206.0, green:219.0, blue:41.0}
            set SpotColor2 to {red:215.0, green:23.0, blue:111.0}
            set SpotColor3 to {red:35.0, green:34.0, blue:33.0}
        end if

        make new spot with properties {name:"Highlight White", color type:spot color, color:SpotColor1}
        make new spot with properties {name:"Under Base", color type:spot color, color:SpotColor2}
        make new spot with properties {name:"Spot Black", color type:spot color, color:SpotColor3}
    end tell

 try
        if theName contains "back" then
            set newName to JobName & "_FB"
        else
            if theName contains "front" then
                set newName to JobName & "_FF"

                set finalPath to newPath & newName
                (save current document in file finalPath as Illustrator) -- make sure finalPath looks like this (... folder:folder:Filename.ai) Name extension is important

            end if
        end if
    end try
    end repeat
end tell

我正在使用您现在提出的方法—它正在寻找变量OpenDocList的定义。保存后我放弃了激活。最后一部分来自Adobe的另存为pdf的变体,但它是Illustrator更新版本的修复程序,因此是OutdatedPathObj(这是我唯一可以真正保存的)。扩展名是Illustrator(与eps、pdf等不同),文件路径是在块中定义的,集合列出了7次。我知道,它不漂亮。我将更新我的文件-它将保存1个打开的文档-我想我的问题可能在if/else部分和/或循环中。就是这样!谢谢你的帮助!我需要将openafileset&WindowList重新排列为文档名,并去掉if语句之间的else。我认为文件路径在Illustrator部分的开头是作为别名建立的,所以我不需要拼出(…folder:folder:Filename.ai)。我会把这个标记为简短的回答。这个脚本每次都有效,完成每项任务,但每三次都会说“无法结束”。我是否错过了一些重要的东西来结束循环?
tell application "Adobe Illustrator"
    activate
    set WindowList to name of documents --List of every open documents name
    repeat with CurrentWindow in WindowList
        open aFile
set theName to name of current document
    set theNamecount to count of theName
    set theOutdatedPathObj to the file path of current document
    set thePath to (POSIX path of theOutdatedPathObj) as string
    set pathCount to count of thePath
    set pathCount to (pathCount - theNamecount)
    set newPath to (text 1 thru pathCount of thePath)
    tell document 1
        set docColorSpace to color space
        if (docColorSpace is CMYK) then
            set SpotColor1 to {cyan:21.0, magenta:0, yellow:100.0, black:0.0}
            set SpotColor2 to {cyan:11.0, magenta:100, yellow:30.0, black:0.0}
            set SpotColor3 to {cyan:0.0, magenta:0, yellow:0.0, black:100.0}
        else
            set SpotColor1 to {red:206.0, green:219.0, blue:41.0}
            set SpotColor2 to {red:215.0, green:23.0, blue:111.0}
            set SpotColor3 to {red:35.0, green:34.0, blue:33.0}
        end if

        make new spot with properties {name:"Highlight White", color type:spot color, color:SpotColor1}
        make new spot with properties {name:"Under Base", color type:spot color, color:SpotColor2}
        make new spot with properties {name:"Spot Black", color type:spot color, color:SpotColor3}
    end tell

 try
        if theName contains "back" then
            set newName to JobName & "_FB"
        else
            if theName contains "front" then
                set newName to JobName & "_FF"

                set finalPath to newPath & newName
                (save current document in file finalPath as Illustrator) -- make sure finalPath looks like this (... folder:folder:Filename.ai) Name extension is important

            end if
        end if
    end try
    end repeat
end tell