list - Applscript- 使用列表选择特定的 Photoshop 动作
问题描述
我一直在尝试使用我所拥有的知识编写一个 Applescript
目前的绊脚石是
- 获取返回的列表选择以运行 Photoshop 操作
- 如何在多个图像上重复操作。
目标 我想使用一个列表从定义的文件夹中提取不同的文件组合(具有设置的命名约定),然后我希望相同的列表选择在多个 photoshop 操作之间进行选择,并通过该操作运行提取的文件组合。
第 1 阶段 - 在运行时打开列表
- 包含一组与 Photoshop 操作相关的名称的列表
- 从列表中选择
第 2 阶段 - 选择包含源图像的文件夹(始终 14 个图像始终具有相同的最后 9 个字符 _0000.tif 到 _0013.tif)
- 选择一个保存文件夹
第 3 阶段 - 依赖于原始列表选择,自动从源图像文件夹中收集文件并通过相应的 photoshop 操作运行它们
例如,如果从列表中选择“动作 1”,则从源文件夹中选择图像“_0001.tiff & _0010.tif”并执行 Photoshop 动作“Action1”
Stage4 保存在选定的“保存文件夹”中
到目前为止的脚本
- 阶段1 -
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
解决方案
我没有找到一种方法来选择文件夹的全部内容并过滤扩展名“tif”、“tiff”、..以及过滤名称包含您的模式的文件。
作为解决方法,我做了两个步骤:
1) 在整个内容中仅选择具有目标扩展名的文件。
2)我遍历这些文件以检查文件名是否包含目标模式。这是通过例程 FnameOK 完成的。
您需要使用 Photoshop 操作和“另存为”来完成以下脚本:
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
推荐阅读
- mysql - MySQL 查询到 COPY/INSERT 行以获取一年的数据
- javascript - 将带有 imaskjs 的后缀添加到 html 输入
- reactjs - 为什么我得到“地图”不是从“反应传单”导出的?
- python - 如何根据烧瓶应用程序上的状态代码运行函数
- c# - (TwinCAT)如何检查任务选项中的“创建符号”框(c#自动化代码)
- google-chrome - Applescript,我如何告诉 chrome 窗口 1 在 chrome 窗口 2 中打开鼠标下的链接作为选项卡?
- c++ - 如何正确响应 HTTP 请求
- python - Numpy:根据邻居进行值替换
- swiftui - 在 SwiftUI 视图中的 TextField 之后使用多个 SecureField 时的奇怪行为
- c++ - 子类型的对象在c ++中使用哪个vtable