user1513077
user1513077

Reputation: 11

Simple script no longer works on Lion

I have a simple Applescript that takes a number of images in a folder that you select and then mirror images the images using Graphic Converter. This script will run if I place it in a new AS file; however, if I try to run it a second time I get the following error "Can't get window 1 of application "GraphicConverter". Invalid index."

This script always ran on OSX 10.6

I'm running OSX 10.7.4 and Graphic Converter 8.1 (latest version).

Here is the script

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

This is driving me crazy!

Upvotes: 1

Views: 228

Answers (1)

jackjr300
jackjr300

Reputation: 7191

GraphicConverter has other windows (visible and invisible), it's preferable to use the document to get the right window. Also, perhaps the image doesn't open, so no window, use a try block.

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

Upvotes: 2

Related Questions