• 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: How to speed up execution time of this script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to speed up execution time of this script


  • Subject: Re: How to speed up execution time of this script
  • From: Bert Groeneveld <email@hidden>
  • Date: Mon, 9 Aug 2010 16:16:19 +0200

Hello Yvan, this indeed works really fast! Absolutely fantastic that you want to share this very smart and intelligent piece of code with a "stranger" like me. This is really of unbelievable help. So thank you a lot!

By the way: I put the first calling of the decoupe handler in a try block, just in case that ma_liste does not at all contain beg.

Bert.


On 9 aug 2010, at 14:56, KOENIG Yvan wrote:


Le 9 août 2010 à 14:10, Bert Groeneveld a écrit :

-- Hope that someone can help speeding up the execution time of the following (part of) my script
-- The execution time is acceptable as long as there are no more than let's say 500 pictures in the the_ImagePath_folder
-- Unfortunately, the fact is that I have more than 10000 pictures inside the_ImagePath_folder
-- What I want to achieve is getting a list of only those filenames (inside the_ImagePath_folder) that start with a given article number


-- This is what I have right now and executes much much much too slow:
tell application "Finder"
set the_ImagePath_folder to alias "Macintosh HD:Applescript:Giving:SpreadTool:HiRes_Images local:" -- a folder that contains 10000 images
set all_the_Hires_Images to name of every file of the_ImagePath_folder --max 20 secs execution time if the_ImagePath_folder contains 10000 images (this is very acceptable since I run this part of the script only once.)
end tell


-- Now the time consuming part for which I badly need help:
set articleNumber to "6615"
set foundImageNames to {}
repeat with Image_Name in my all_the_Hires_Images
	if Image_Name starts with articleNumber then
		set foundImageNames to foundImageNames & Image_Name
	end if
end repeat


Here is the way I do that in plain vanilla:

set ma_liste to {"3123_aze", "456_fg", "3123_aza", "456_fgz", "3123_azes", "456_fgn", "3123_azex", "456_fsg"}

set my_1st_delim to "|¬|"
set liste_en_texte to my recolle(ma_liste, my_1st_delim)
set beg to "456"
set my_2nd_delim to my_1st_delim & beg
set en_liste to items 2 thru -1 of my decoupe(liste_en_texte, my_2nd_delim)


repeat with un_objet in en_liste
set vraie_chaine to beg & item 1 of my decoupe(un_objet, my_1st_delim)
-- log vraie_chaine
-- do your duty with it

end repeat


--=====

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

--=====

on recolle(l, d)
	local oTIDs, l
	set oTIDs to AppleScript's text item delimiters
	set AppleScript's text item delimiters to d
	set t to l as text
	set AppleScript's text item delimiters to oTIDs
	return t
end recolle

--=====

Yvan KOENIG (VALLAURIS, France) lundi 9 août 2010 14:55:57




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


This email sent to email@hidden




_______________________________________________
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: 
 >How to speed up execution time of this script (From: Bert Groeneveld <email@hidden>)
 >Re: How to speed up execution time of this script (From: KOENIG Yvan <email@hidden>)

  • Prev by Date: Re: Libraries and effiency
  • Next by Date: Re: Libraries and effiency
  • Previous by thread: Re: How to speed up execution time of this script
  • Next by thread: Re: How to speed up execution time of this script
  • Index(es):
    • Date
    • Thread