首页 > 解决方案 > 重复多个列表的内容

问题描述

下面是我一直在工作的脚本的简化版本(并得到了帮助)。一切正常。我想开发这个,所以在启动脚本时,它会显示带有按钮的对话框,执行以下操作。

按钮一同时运行“Spec1”和“Spec2”

按钮二同时运行“Spec2”和“Spec3”

按钮三显示一个列表对话框以选择“Spec1”、“Spec2”、“Spec3”(就像脚本已经做的那样)

最终的脚本会有更多的规范,但这足以说明我想要实现的目标

谢谢

-- Spec realted file extensions

--Spec 1
set ListSpec1 to {"_0006", "_0007", "_0010", "_0011"}

--Spec 2
set ListSpec2 to {"_0000", "_0001", "_0002", "_0003", "_0004", "_0005"}

--Spec 3
set ListSpec3 to {"_0006"}


-- Obtain user choice of PS action 
set PhotoshopActionList to {"Spec1", "Spec2", "Spec3"}
set ChosenSpec to choose from list PhotoshopActionList with title "Actions       Picker" with prompt "Choose Action?"


-- If user cancels, then terminate the script
if ChosenSpec is false then
error number -128 (* user cancelled *)
else
set ChosenSpec to ChosenSpec's item 1 (* extract choice from list*)
end if

--Set image source folder
set SourceFolder to (choose folder with prompt "Choose Base Images:")
set FoldertoReplace to SourceFolder & ChosenSpec as text

--set image save folder
set DestinationFolder to (choose folder with prompt "Choose Save Location:")
set filelocation to DestinationFolder as text


--Setting Files list
tell application "Finder" to set filesList to files of entire contents of        SourceFolder whose name ends with ".tif"

repeat with CurrentFile in filesList
tell application "Finder"
    set NameF to name of CurrentFile
    set currentFileAlias to (CurrentFile as alias) as text
end tell


-- Canadian Files Lists 
if ChosenSpec is "Spec1" then
    set theListSpecToUse to ListSpec1
else if ChosenSpec is "Spec2" then
    set theListSpecToUse to ListSpec2
else
    set theListSpecToUse to ListSpec3
end if


-- the file name contains a valid pattern, then process the file
if FNameOK(NameF, theListSpecToUse) then

    --open photoshop
    tell application "Adobe Photoshop CC 2017"
        open alias currentFileAlias

        --Canadain Actions
        if ChosenSpec is "Spec1" then
            do action "Spec1" as text from "Specs"
        else if ChosenSpec is "Spec2" then
            do action "Spec2" as text from "Specs"
        else if ChosenSpec is "Spec3" then
            do action "Spec3" as text from "Specs"
        end if


        --Saving to Format


        -- Canadian Saves
        if ChosenSpec is "Spec1" then
            save current document in filelocation as TIFF with options {class:TIFF save options, image compression:LZW, transparency:true, embed color profile:true}
        else if ChosenSpec is "Spec2" then
            save current document in filelocation as TIFF with options {class:TIFF save options, image compression:LZW, transparency:true, embed color profile:true}
        else
            save current document in filelocation as PNG with options {class:PNG save options, compression:9, interlaced:false} appending no extension with copying
        end if

        --Close Photoshop Document
        close current document without saving

    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

标签: applescript

解决方案


推荐阅读