2015-06-26 38 views
0

我想寫一個腳本,需要多個項目,我已經在Photoshop中編輯並在Illustrator中打開它們,進行一些更改,保存一堆不同的方法,然後關閉項目並打開下一個項目。除了在Illustrator中打開photoshop文件之外,我已經可以工作了。所有的項目將位於同一個文件夾中,所以我嘗試使用查找器將所有這些文件設置爲列表,然後在Illustrator中打開文件。下面是代碼:如何使用Applescript在Illustrator中打開Photoshop項目?

tell application "Finder" 
    set theFiles to files of folder POSIX file "/Volumes/Assets/BLG.com Images/Images for Renaming/Photoshop Files" as list 
end tell 
repeat with f in theFiles 
    tell application "Adobe Illustrator" 
     activate 
     open f with options {class:Photoshop options, preserve hidden layers:true, preserve layers:true} without dialogs 
     set allLayers to layers of document 1 
     set allImages to page items of document 1 
     repeat with lay in allLayers 
      set visible of lay to true 
     end repeat 
     repeat with img in allImages 
      set scaleMatrix to get scale matrix horizontal scale 416 vertical scale 416 
      transform img using scaleMatrix 
     end repeat 
     selectobjectsonactiveartboard document 1 
     delay 2 
     do script "Fit Artboard to Selected" from "Fit Artboard" 
     set visible of layer 2 of document 1 to false 
     set visible of layer 4 of document 1 to false 
     delay 2 
     do script "Raw Copper Save" from "RC" 
     set visible of layer 5 of document 1 to false 
     delay 2 
     do script "Architectural Copper Save" from "AR" 
     set visible of layer 6 of document 1 to false 
     delay 2 
     do script "Satin Antique Save" from "SA" 
     set visible of layer 7 of document 1 to false 
     delay 2 
     do script "Brushed Nickel Save" from "BN" 
     set visible of layer 8 of document 1 to false 
     delay 2 
     do script "Polished Nickel Save" from "PN" 
     set visible of layer 10 of document 1 to false 
     set visible of layer 9 of document 1 to false 
     delay 2 
     do script "Antique Copper Save" from "AC" 
     set visible of layer 11 of document 1 to false 
     delay 2 
     do script "Verdigris Patina Save" from "VG" 
     set visible of layer 12 of document 1 to false 
     delay 2 
     do script "Satin Verdigris Patina Save" from "SV" 
     set visible of layer 13 of document 1 to false 
     set visible of layer 2 of document 1 to true 
     delay 2 
     do script "Black Save" from "BK" 
     set visible of layer 14 of document 1 to false 
     set visible of layer 2 of document 1 to false 
     set visible of layer 15 of document 1 to false 
     delay 2 
     do script "Default Save" from "Default" 
     delay 2 
     save document 1 in "/Volumes/Assets/BLG.com Images/Images for Renaming/Illustrator Files" as Illustrator 
     delay 2 
     close document 1 
    end tell 
end repeat 

目前該代碼將打開在Photoshop中,而不是在Illustrator中的文件,這真的讓我困惑,因爲我說的是Illustrator的應用程序打開它,沒有取景器。任何有識之士都會非常感激。試圖找出這個問題,一直在我的桌子上敲我的頭。

回答

1

最後嘗試

tell application "Finder" 
    set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files" as alias list 
end tell 
tell application "Adobe Illustrator" 
    set user interaction level to never interact 
    activate 
    set photoshopOptions to {class:Photoshop options, preserve layers:true, preserve hidden layers:true} 
    set IllustratorPreferences to {class:Illustrator preferences, Photoshop file options:photoshopOptions} 
end tell 
repeat with f in theFiles 
    tell application "Adobe Illustrator" 
     open f without dialogs 
     set allLayers to layers of document 1 

… 
+0

導入選項仍然彈出。我覺得很難相信沒有什麼方法可以自動化,但我猜這是可能的,你必須點擊。感謝您的幫助!非常感謝! – Adam

+0

不要緊,這是行不通的!只要確保在Illustrator上進行硬重啓,就可以進行首選項更改。 – Adam

0

您可以告訴Finder用特定的應用程序打開文檔。 請試試這個(保持註釋掉開行)

tell application "Finder" 
    set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files" 
end tell 
activate application "Adobe Illustrator" 
repeat with f in theFiles 
    tell application "Finder" to open f using application file id "com.adobe.illustrator" 
    tell application "Adobe Illustrator" 

     -- open f with options {class:Photoshop options, preserve hidden layers:true, preserve layers:true} without dialogs 
     set allLayers to layers of document 1 
… 
+0

這將打開在Illustrator的文件,但我之所以用以我的方式打開命令是因爲我需要在程序中保留圖層,這些是我需要的選項。我希望它在打開每個文件時不會給我那個彈出窗口,因爲我不想在運行時仔細看這個腳本 – Adam

1

這是否工作

tell application "Finder" 
    set theFiles to files of folder "Assets:BLG.com Images:Images for Renaming:Photoshop Files" as alias list 
end tell 
tell application "Adobe Illustrator" 
    activate 
    tell Photoshop file options of settings 
     set preserve hidden layers to true 
     set preserve layers to true 
    end tell 
end tell 
repeat with f in theFiles 
    tell application "Adobe Illustrator" 
     open f without dialogs 
     set allLayers to layers of document 1 
… 
相關問題