Applescript- 使用列表 Select 特定的 Photoshop 动作

Applscript- Use List to Select Specifc Photoshop Action

我一直在尝试使用我所掌握的知识来编写 Applescript

当前的绊脚石是

-获取返​​回的列表 selection 到 运行 photoshop 操作

-如何对多张图片重复操作。

瞄准 我想使用一个列表从定义的文件夹中提取不同的文件组合(具有设置的命名约定), 然后我希望同一个列表 selection 在多个 photoshop 操作和 运行 通过该操作提取的文件组合之间进行选择。

阶段 1 -on 运行正在打开一个列表

-包含一组与 photoshop 操作相关的名称的列表

-select 来自列表

第 2 阶段 -选择包含源图像的文件夹(总是 14 张图像,最后 9 个字符总是相同 _0000.tif 到 _0013.tif)

-选择保存文件夹

阶段 3 -依赖于原始列表 selection,自动从源图像文件夹中收集文件,并通过相应的 photoshop 操作 运行 它们

例如,如果 "Action 1" 从源文件夹中的列表 select 图像“_0001.tiff & _0010.tif”中选择并执行 photoshop 操作 "Action1"

第四阶段 保存在选定的 "save folder"

到目前为止的脚本

--第一阶段--

set PhotoshopActionList to {"Action1", "Action2", "Action3", "Action4", "Action5"}

set ActionrequiredAnswer to choose from list PhotoshopActionList with title "Actions Picker" with prompt "Choose Action?"


if ActionrequiredAnswer is false then
    error number -128 (* user cancelled *)
else
    set ActionrequiredAnswer to ActionrequiredAnswer's item 1 (* extract choice from list*)
end if

end run

--第二阶段--

property SourceFolder : missing value
property destinationFolder : missing value

if SourceFolder = missing value then
    set SourceFolder to (choose folder with prompt "Choose Base Images:")
    set destinationFolder to (choose folder with prompt "Choose Save Location:")
else

    tell application "Finder"
        set theFolders to every item of entire contents of SourceFolder as list
        repeat with thisFolder in theFolders
            make new alias file at destinationFolder to thisFolder
        end repeat
    end tell
end if

--第三阶段--

tell application "Finder"
    set filesList to {files of entire contents of SourceFolder contains "_001", "_002", "003"} as alias list
end tell

tell application "Adobe Photoshop"
   repeat with aFile in filesList
       open aFile

       do action "Action1" from "Actionsfolder"
end tell

--第四阶段--

save currentDocument in folder destinationFolder as JPEG

我没有找到 select 文件夹的全部内容并过滤扩展名 'tif'、'tiff'.. 并过滤名称包含您的模式的文件的方法。

作为解决方法,我执行了 2 个步骤:

1) select 在整个内容中只有具有目标扩展名的文件。

2) 我循环遍历这些文件以检查文件名是否包含目标模式。这是由例程 FnameOK 完成的。

您需要使用 Photoshop 动作和 'save as':

完成下面的脚本
set PhotoshopActionList to {"Action1", "Action2", "Action3", "Action4", "Action5"}
set ListOK to {"_001", "_002", "003"}
set ActionRequiredAnswer to choose from list PhotoshopActionList with title "Actions  Picker" with prompt "Choose Action?"
if ActionRequiredAnswer is false then
    error number -128 (* user cancelled *)
else
    set ActionRequiredAnswer to ActionRequiredAnswer's item 1 (* extract choice from list*)
end if

set SourceFolder to (choose folder with prompt "Choose Base Images:")
set DestinationFolder to (choose folder with prompt "Choose Save Location:")

tell application "Finder" to set filesList to files of entire contents of SourceFolder whose name extension is in {"tiff", "tif"}

repeat with aFile in filesList
    tell application "Finder" to set NameF to name of aFile
    if FNameOK(NameF, ListOK) then -- the file name contains a valid pattern, then process the file
        tell application "Adobe Photoshop" 
            open (aFile as alias)
            -- perform action selected
            -- save as to Destination Folder
        end tell
    end if
end repeat

on FNameOK(Local_Name, LocalList) -- check if the file name contains an element of the list
    set LocalCheck to false
    repeat with OneItem in LocalList
        if Local_Name contains OneItem then
            return true
        end if
    end repeat
    return false
end FNameOK