• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Finder crash on duplicate file statement
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder crash on duplicate file statement


  • Subject: Re: Finder crash on duplicate file statement
  • From: KOENIG Yvan <email@hidden>
  • Date: Sat, 11 Sep 2010 19:23:31 +0200


Le 11 sept. 2010 à 17:30, Jim Brandt a écrit :

Yvan,

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


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Finder crash on duplicate file statement (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: iChat script has stopped working
  • Next by Date: Re: iChat script has stopped working
  • Previous by thread: Re: Finder crash on duplicate file statement
  • Next by thread: (no subject)
  • Index(es):
    • Date
    • Thread