Le 11 sept. 2010 à 17:30, Jim Brandt a écrit : Hello
It's not clear in your message. Is your code encapsulated in a tell Finder block ?
When I wish to check that a copy process is ended, I use a loop checking that the physical size no longer change.
tell application "System Events" to tell disk item "path_2_my_file" set old_size to -1 repeat delay .5 set new_size to physical size if new_size = old_size then exit repeat set old_size to new_size end repeat end tell
Yvan KOENIG (VALLAURIS, France) samedi 11 septembre 2010 16:15:59
Yes the code is in a tell Finder block, as I said in the line above the code :-)
Oops, it seams that my eyes where wide shut :-(
I don't think it's the copy process not completing that is the problem. The crash happens DURING the copy process. I'm not even at a point in the code where I can check for the copy being complete... it's dropping into the on error code of the try block.
It seems that I was not clear. I hope that this time, I'm. I don't know perl, but it seams that the perl command is writing the file Index_file. My loop wait until the perl task is ended. I wish to add that I'm always surprised when I see a variable like POSIXFileName which doesn't store a file name but a file path.
set MactoDOS to "'s/\\015/\\015\\012/g'" set POSIXFileName to POSIX path of file Index_file set cmd to "perl -i -pe " & MactoDOS & " \"" & POSIXFileName & "\"" do shell script (cmd) tell application "System Events" to tell disk item "path_2_my_file" (* POSIXFileName *) set old_size to -1 repeat delay .5 set new_size to physical size if new_size = old_size then exit repeat set old_size to new_size end repeat end tell set step to "Step 13" set mess to step & " - Copy " & Index_file & " to " & f_MainFolder TextLib's Message(mess, logfile)
try duplicate file Index_file to folder f_MainFolder with replacing on error the error_message number the error_number set mess to "Error in " & step & ": " & the error_number & ". " & the error_message TextLib's Message(mess, logfile) my do_error(error_number, mess) end try
In my loop I use System Events because I hate the Finder but you may use it if you wish. From my point of view, in most of the tasks, the Finder is wasting processor cycles adding its own layer above the System Events one so I prefer speaking directly to System Events. In French, those trusting in god say :
Il vaut mieux parler au bon dieu qu'à ses saints.
Yvan KOENIG (VALLAURIS, France) samedi 11 septembre 2010 19:23:25
|