Re: script works when reading from DVD but not when reading from hard disk
Re: script works when reading from DVD but not when reading from hard disk
- Subject: Re: script works when reading from DVD but not when reading from hard disk
- From: Brian Christmas <email@hidden>
- Date: Wed, 7 Oct 2009 14:39:29 +1100
G'day
Who cares, well I do; I've got a client who runs thousands of folders inside sub-folders etc.
So. I ran some tests. Very interesting results.
set temp to (path to desktop) set temp2 to temp & "Tester" as text set temptime to current date repeat with x from 1 to 1000 tell application "System Events" set aliasToNewFolder to (make new folder at end of folder ((temp2) as text) with properties {name:((name of (container of file (((temp) & "Untitled 2.pages") as text)) as text) & x)}) --as alias end tell end repeat display dialog (((current date) - (temptime))) --> 56 inside. 56 outside
Using the tell block both outside & inside the repeat loop gave 56 seconds to create 1000 new folders under System events.
set temp to (path to desktop) set temp2 to temp & "Tester" as text set temptime to current date set temptime to current date repeat with x from 1 to 1000 tell application "Finder" set aliasToNewFolder to (make new folder at temp2 with properties {name:((name of (container of file (((temp) & "Untitled 2.pages") as text)) as text) & x)}) as alias end tell end repeat display dialog (((current date) - (temptime))) --> 44 seconds inside This is the interesting bit. Putting the tell block outside the repeat loop crapped the finder blind. It periodically stopped, then hung after several tries.
However, putting the tell inside the repeat as shown and it came out at 44 seconds. The finder, if used correctly, is faster. Who would have thought to put the tell inside the repeat loop.
Regards
Santa
On 07/10/2009, at 12:28 PM, Shane Stanley wrote: On 7/10/09 10:03 AM, "Brian Christmas" < email@hidden> wrote: Shane, which would be the fastest, your method of getting a container,
then creating a folder, or creating the folder in one line as I
posted, and Mari originally tried?
I'm tempted to answer: Who cares? Really, any difference is only worth worrying about if it's massive, or you're doing it many thousands of times. But if I had to guess, I'd put my money on doing it outside the Finder. -- Shane Stanley < email@hidden> AppleScript Pro, April 2010, Florida < http://www.applescriptpro.com>
|
_______________________________________________
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