Re: Very slow AppleScript
Re: Very slow AppleScript
- Subject: Re: Very slow AppleScript
- From: "emile.a.schwarz" <email@hidden>
- Date: Sat, 02 Mar 2013 09:55:09 +0100 (CET)
Hi,
preliminary test on a three items folder was not significative, so I checked another with 41 items to test and ..
it tooks around 20 seconds to get all references (after pressing in the OK button/selecting the target folder), then the checkings started.
I will make more checkings later with a folder where there are files to modify.
Christopher:
I would avoid to write this script if people correctly set the file extension to what is really in the file ;-).
Time difference is impressive.
Good to note: this is not the case when running on 10.7.5. This is the main reason why I asked: I feared that my system was in trouble.
Thank you all,
Emile
> Message du 01/03/13 21:01
> De : email@hidden
> A : email@hidden
> Copie à :
> Objet : AppleScript-Users Digest, Vol 10, Issue 75
>
> Send AppleScript-Users mailing list submissions to email@hidden To subscribe or unsubscribe via the World Wide Web, visit https://lists.apple.com/mailman/listinfo/applescript-users or, via email, send a message with subject or body 'help' to email@hidden You can reach the person managing the list at email@hidden When replying, please edit your Subject line so it is more specific than "Re: Contents of AppleScript-Users digest..." Today's Topics: 1. Re: Very slow AppleScript (emile.a.schwarz) 2. Re: Very slow AppleScript (Shane Stanley) 3. Re: Very slow AppleScript (Christopher Stone) ---------------------------------------------------------------------- Message: 1 Date: Fri, 01 Mar 2013 13:21:57 +0100 (CET) From: "emile.a.schwarz" To: email@hidden Subject: Re: Very slow AppleScript Message-ID: Content-Type: text/plain; charset="utf-8" Hi, I removed what my code really does because it is not relevant. Also not relevant everything excepted the following line: set ItemToChange to item 1 of SelectedFldr This line takes 7 seconds by its own. When set in a 22 items loop, it grows to 20 seconds to deals with a file (in the complete script). The following line takes a bit more than one second to return the result (but the code is useless): set ItemToChange to item 1 of front window What the complete script do is scan the front window (or a folder the user choose), in a repeat statement, reads the first 10 bytes of each file, compare what he got to a large list of nested if elseif .../... end if block and if something is found, set the file name extension from what is wrongly set (cbr, cbz, cb7, whatever) to rar, zip or 7z. (I omitted many other entries. Originally, I was thinking the faultive (was me) was in that very long if block. I commented it out and saw that I was wrong: the slow line is the one I gave earlier in this mail. Now you know (more or less) what the OP is doing (or try to do), but this is not relevantr to the question unless a better way exists to do that. Is it crystal clear now ? An idea someone ? Emile PS: running the shared code from the original post would let you see the time done to just get a reference to an item from a Finder folder. I was thinking that I was correctly displaying my problem, but I was wrong. ;-:) -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ Message: 2 Date: Fri, 01 Mar 2013 23:32:50 +1100 From: Shane Stanley To: AS users Subject: Re: Very slow AppleScript Message-ID: Content-Type: text/plain; charset="utf-8" On 01/03/2013, at 11:21 PM, emile.a.schwarz wrote: > Hi, > > > I removed what my code really does because it is not relevant. > > > Also not relevant everything excepted the following line: > > > set ItemToChange to item 1 of SelectedFldr > > > This line takes 7 seconds by its own. When set in a 22 items loop, it grows to 20 seconds to deals with a file (in the complete script). You repeatedly asking the Finder to get the first item of the folder. Why not get them all once, and loop through the list: set SelectedFldr to choose folder default location (fwFldr as alias) # get the items in the target folder set theItems to items of SelectedFldr repeat with i from 1 to count of theItems set ItemToChange to item i of theItems # I removed the working code from here end repeat -- Shane Stanley 'AppleScriptObjC Explored' -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ Message: 3 Date: Fri, 01 Mar 2013 10:23:41 -0600 From: Christopher Stone To: Applescript Users List Subject: Re: Very slow AppleScript Message-ID: Content-Type: text/plain; charset="utf-8" On Mar 01, 2013, at 06:32, Shane Stanley wrote: > set theItems to items of SelectedFldr ______________________________________________________________________ Hey Folks, When speed is at issue you should never use Finder references if avoidable. In a Finder-Tell block where the contents of the folder () in question is only 30 items. items of --> 0.3212 sec items of as alias list --> 0.0393 sec Big difference. -- Best Regards, Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: ------------------------------ _______________________________________________ AppleScript-Users mailing list email@hidden https://lists.apple.com/mailman/listinfo/applescript-users End of AppleScript-Users Digest, Vol 10, Issue 75 *************************************************
_______________________________________________
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