• 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 can I speed up execution time of this script in case of many files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I speed up execution time of this script in case of many files


  • Subject: Re: How can I speed up execution time of this script in case of many files
  • From: Peter Baxter <email@hidden>
  • Date: Fri, 02 Aug 2013 12:41:51 +1000

Hi Bert,

Your script keeps referring back to the original files, slowing up your script by multiple repetitions.  It is better to get the properties of your files into a list as a database and then refer to them.  The following script shows ho I avoid having to refer back to the files multiple times.  You should then be able to modify your script the same way:
set MyList to {}
set TotalList to {}
tell application "Finder"
set myFiles to the files in folder "Documents" of folder "myDocuments" of folder "Users" of startup disk


repeat with i from 1 to the number of items in myFiles
set thisItem to item i of myFiles
set myInfo to the properties of thisItem
set the end of MyList to myInfo
end repeat
activate
display dialog "Start now" giving up after 2 -- This shows when operations on the list start so you can see the change in speed.  Delete this once you get it.
end tell
-- all operations after this refer to your list and don't need to refer to the original files
repeat with i from 1 to the number of items in MyList
set thisNewItem to the name of item i of MyList
set thisNewSize to the size of item i of MyList
set the end of TotalList to thisNewItem & " " & thisNewSize & return
end repeat
TotalList
On 02/08/2013, at 7:19 AM, Bert Groeneveld <email@hidden> wrote:

on Preflight_Images()
set myFiles to {}
tell application "Finder"
set myFiles to myFiles & every file of the_Preflight_WEBSHOP_subfolder
set myFiles to myFiles & every file of the_Preflight_IMAGEBANK_subfolder
end tell
set number_of_files to (count of myFiles)

set First_File_sizes to {}
-- repeat with aFile in my myFiles: Execution error!!!
repeat with aFile in myFiles
tell application "Finder"
set size_of_a_file to size of aFile
end tell
set the end of First_File_sizes to size_of_a_file -- create list of file sizes
end repeat
delay 5 -- stabilize time
set Stabilized_Files to {}
repeat with counter from 1 to number_of_files
-- set aFile to item counter of my myFiles: Execution error!!!
set aFile to item counter of myFiles
tell application "Finder"
set size_of_a_file to size of aFile
end tell
if size_of_a_file = item counter of First_File_sizes then
set the end of Stabilized_Files to item counter of myFiles
end if
end repeat
-- further processing
end Preflight_Images

 _______________________________________________
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 can I speed up execution time of this script in case of many files (From: Bert Groeneveld <email@hidden>)

  • Prev by Date: How can I speed up execution time of this script in case of many files
  • Next by Date: Re: How can I speed up execution time of this script in case of many files
  • Previous by thread: How can I speed up execution time of this script in case of many files
  • Next by thread: Re: How can I speed up execution time of this script in case of many files
  • Index(es):
    • Date
    • Thread