【问题标题】:How to run Applescript Photoshop Automate Batch of an Action如何运行 Applescript Photoshop 自动批处理操作
【发布时间】:2019-06-24 16:31:20
【问题描述】:

我正在尝试制作一个 Applescript,它将启动 Photoshop 并调用自动批处理功能来运行特定的操作。我这样做的经验为零,并且仅从搜索中获得了 sn-ps 代码。我想知道是否有人可以帮助我解决这个问题。特别是如果可以将源文件夹传递给批处理调用,然后如何进行批处理调用。

特别是,我在试图弄清楚如何:

  1. 将源文件夹传递到批处理选项

  2. 在我的 Photoshop 中调用 Batch_Options 中的特定操作

  3. 使用这些选项运行批处理调用

我已经更新了部分存在的最新代码......

tell application "Finder"
    set sourceFolder to "Macintosh HD:Users:Joe:Desktop:Temp:" as alias
    set folderList to every item of folder sourceFolder as alias list

    do shell script "echo File Names are: " & folderList
end tell

tell application "Adobe Photoshop CC 2018"
    set action_set_name to "Save as Photoshop PDF"
    activate
    try
        set Batch_Options to {class:batch options, destination:save and close, error file:Error_File, file naming:{document name lower, extension lower}, macintosh compatible:true, override open:false, override save:true, suppress open:true, suppressprofile:true, unix compatible:true, windows compatible:true}
        batch "Save" from files folderList from action_set_name with options Batch_Options
    end try
end tell

输出:

“文件名是:Macintosh HD:Users:Joe:Desktop:Temp:Creature01_CO_v003.psdMacintosh HD:Users:Joe:Desktop:Temp:SecretLaboratory.psd”

Photoshop 打开,然后什么也没有发生...

【问题讨论】:

  • 根据我使用 AppleScript 的经验,我发现最好将代码限制为击键:tab、enter 等。它根本不可读,但通常性能更好跨度>
  • 很好,但不是我想要在这里完成的目标
  • @GalAbra 可读性是为什么这种方法(并鼓励它)只是最后手段的根本原因,而且通常甚至不是。您可能很幸运或在实践中使用此类脚本的情况有限,但众所周知,它们是脆弱的、喜怒无常的、缓慢的、不方便的,以及许多其他形容英国退欧的形容词。这是 AppleScripting 的脱欧。
  • @CJK 喜欢你的评论。不幸的是,问题是 AS 没有提供足够的文档来编写稳定的代码
  • @GalAbra 我能给出的最好建议是在线查找示例,进行实验,破坏一些脚本,再次修复它们,然后以不同的方式重新编写它们。这基本上就是您学习任何脚本或编程语言的方式。还有一些decent online PDFs。这一切都是错误的尝试,直到有一天它不是。

标签: applescript photoshop


【解决方案1】:

以下似乎在 Automator 中起作用:

    tell application "Finder"
        set sourceFolder to "Macintosh HD:Users:Joe:Desktop:Temp:" as alias
        set folderList to every item of folder sourceFolder as alias list
        do shell script "echo File Names are: " & folderList

        #Alias list needs to be converted to a string for it to work in Photoshop batch call
        set FileNames to {}
        repeat with i from 1 to the count of folderList
            set current_file to item i of folderList
            copy current_file as text to the end of FileNames
        end repeat

        #Setup error log
        set err_log to (sourceFolder as string) & "Error_Log.txt"
        if not (exists file err_log) then
            make new file at sourceFolder with properties {name:"Error_Log.txt"}
        end if
    end tell

    tell application "Adobe Photoshop CC 2018"
        set action_set_name to "SetA"
        activate
        set Batch_Options to {class:batch options, destination:save and close, error file:err_log, file naming:{document name lower, extension lower}, macintosh compatible:true, override open:false, override save:true, suppress open:true, suppressprofile:true, unix compatible:true, windows compatible:true}
        #First arg is the Action Name, second is the list of files, third is the Action Set Name
        batch "ActionA" from files FileNames from "SetA" with options Batch_Options
    end tell

【讨论】:

    猜你喜欢
    • 2021-01-15
    • 1970-01-01
    • 1970-01-01
    • 2011-06-04
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    • 2014-09-28
    • 2014-06-20
    相关资源
    最近更新 更多