2012-07-09 22 views
1

我有一個簡單的Applescript,需要選擇一個文件夾中的多個圖像,然後使用圖形轉換器鏡像圖像。如果將該腳本放入新的AS文件中,該腳本將運行;但是,如果我嘗試第二次運行它,則會出現以下錯誤:「無法獲取應用程序的窗口1」GraphicConverter「。索引無效。」簡單的腳本不再適用於Lion

該腳本始終運行在OSX 10.6

我運行OSX 10.7.4和圖形轉換器8.1(最新版本)。

這裏是腳本

tell application "Finder" 
    activate 
    set loopFinish1 to 0 
    set pathName to (choose folder with prompt "Choose Folder Containing Images") 
    set fileList1 to every file of folder pathName 
    set loopFinish1 to count of items of fileList1 
end tell 

tell application "GraphicConverter" 
    activate 
    repeat with i from 1 to loopFinish1 
     set currentFile to item i of fileList1 
     open currentFile as alias 
     mirror window 1 in horizontal 
     close window 1 saving yes 
    end repeat 
end tell 

這是推動我瘋了!

回答

2

GraphicConverter有其他窗口(可見和不可見),最好使用文檔來獲得正確的窗口。 此外,也許圖像不打開,所以沒有窗口,使用try塊。

activate 
set pathName to (choose folder with prompt "Choose Folder Containing Images") 
tell application "Finder" to set fileList1 to (document files of folder pathName) as alias list 

tell application "GraphicConverter" 
    activate 
    repeat with tFile in fileList1 
     set currentDoc to open tFile 
     set CurrWindow to (first window whose its document is currentDoc) 
     mirror CurrWindow in horizontal 
     close currentDoc saving yes 
    end repeat 
end tell 
相關問題