repeat try name of window 1 exit repeat on error delay 1 end try end repeat
Enter a try / end try block try to get the name of the document's window if the instruction behaves flawlessly, the document is open, exit the loop if the document isn't completely opened, the instruction issue an error so wait one second then repeat until end of the open process.
At first try, without this loop, I got an error. I inserted a wait instruction an it behaved flawlessly so I decided to insert a loop waiting the required time, quite no more
I assumed that Graphic Converter was not already open with an open window. I my assumption is wrong, a slightly enhanced code is required :
on open (droppedItems) set destFldr to "" & (path to documents folder) & "scaled_picture_folder_Originals:" set the text item delimiters of AppleScript to {""} tell application "Finder" to open destFldr repeat with aFile in droppedItems set theFile to (aFile as string) if theFile ends with ":" then set theName to item -2 of my decoupe(theFile, ":") else set theName to item -1 of my decoupe(theFile, ":") end if set destFile to destFldr & theName
display dialog theName as string
tell application "GraphicConverter" activate set nbw to count of windows open {alias theFile} repeat if (count of windows) > nbw then exit repeat else set nbw to count of windows delay 1 end if end repeat save window 1 in (destFile as string) beep close window 1 end tell end repeat end open
--=====
on decoupe(t, d) local oTIDs, l set oTIDs to AppleScript's text item delimiters set AppleScript's text item delimiters to d set l to text items of t set AppleScript's text item delimiters to oTIDs return l end decoupe
--=====
CAUTION In my late message I made a wrong copy paste so I left the main error of the original handler.
You wrote (and I left) : set destFldr to destFldr & theName … save window 1 in (destFldr as string)
which gave : 1st file : the_path_to_store_in:file1.jpg 2nd file : the_path_to_store_in:file1.jpgfile2.jpg 3rd file : the_path_to_store_in:file1.jpgfile2.jpgfile3.jpg …
It must be edited this way :
set destFile to destFldr & theName … save window 1 in (destFile as string)
which give : 1st file : the_path_to_store_in:file1.jpg 2nd file : the_path_to_store_in:file2.jpg 3rd file : the_path_to_store_in:file3.jpg …
Yvan KOENIG (VALLAURIS, France) samedi 23 octobre 2010 16:23:16
|