Wait until automator action is finished...HELP!

I work at a photo studio that requires the moving of files to batch burning folders, the file names which are based on an excel document cell. My problem with the script I have created (which outsources the finding and transferring to automator) is that I have to do a delay of about 10 seconds between repeats (sometimes up to 800 files). Does anybody have any clue as to a few lines that would say ‘wait until automator has finished the workflow’? Also, a script that finds files based on the text content of the clipboard and moves them to a defined folder (to eliminate outsourcing to Automator), and to repeat this process until a cell in Excel comes up blank.

Here is the current script:
tell application “Microsoft Excel”
Activate
Select Range “R3C1”
CopyObject Selection
Select Range “r3”
Delete Selection Shift xlUp
end tell
tell application “Automator”
activate
end tell
tell application “System Events”
tell process “Automator”
keystroke “r” using [command down]
delay 1
keystroke “v” using [command down]
delay 1
keystroke (ASCII character of 13)
end tell
end tell
delay 10

Dan T

Yeah, delays aren’t a good idea. You might try saving your script as an Application, and then have Automator launch it at the end of the workflow. E.G. drag in the “Run AppleScript” action (in the Automator Library) and say tell app “myapp” to activate. Then it would just be a matter of launching your script application once manually, and let Automator take care of the rest.

I hate using automator for the majority of the project. I would actually prefer to have the automator action I’m using written within Applescript (Find Finder Items, Get Specified Finder Items, Copy Finder Items). For the length of the application I’m making, using Automator is unreasonable, as it slows down the system BIGTIME (and I’m working on a dual 2.5 w/ 6gb of ram).

Dan

If you pop open an Activity Monitor window and observe a running delay command all on its own, you’ll see that it can lock up a processor no matter what the mHz. Anywho, not to get off-topic, but I don’t see anything that’s preventing you from eliminating Automator. Here follows a tiny example. You’ll have to fiddle with this a bit, especially if there’s a chance that spotlight will return multiple results, but I just wrote it quickly to illustrate the possibilities.

set myFileName to "foo.txt" -- the file you're looking for
set searchTree to "~/Desktop/" -- where to look for the file (includes subfolders)
set copyFolder to "~/Desktop/Test/" -- where to copy the file
set myFile to do shell script "mdfind -onlyin " & searchTree & " kMDItemFSName = '" & myFileName & "'"
do shell script "cp " & myFile & " " & copyFolder & myFileName

Okay, to satisfy my own curiosity, I rewrote it so that it will copy everything that Spotlight finds. In my test I had “foo.t” and “foo.txt” in different folders on the desktop, and this copies them both to the test folder:

set oldDelims to AppleScript's text item delimiters
set myFileName to "foo.t" -- the file you're looking for
set searchTree to "~/Desktop/" -- where to look for the file (includes subfolders)
set copyFolder to "~/Desktop/Test/" -- where to copy the file
set myFile to do shell script "mdfind -onlyin " & searchTree & " kMDItemFSName = '" & myFileName & "'"
set AppleScript's text item delimiters to return
set myFile to myFile's text items as list
set AppleScript's text item delimiters to oldDelims
repeat with x in myFile
	do shell script "cp " & x & " " & copyFolder
end repeat