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: Shane Stanley <email@hidden>
- Date: Wed, 07 Oct 2009 17:43:28 +1100
- Thread-topic: script works when reading from DVD but not when reading from hard disk
On 7/10/09 2:39 PM, "Brian Christmas" <email@hidden> wrote:
> Who cares, well I do; I've got a client who runs thousands of folders inside
> sub-folders etc.
In that case you'd want to optimise things, and use neither of those. They
might be written as one-lines, but they execute as multiple commands every
time. Look at the log:
tell application "Finder"
get name of container of file "Macintosh HD:Users:shane:Desktop:Untitled
2.pages"
--> "Desktop"
make new folder at "Macintosh HD:Users:shane:Desktop:Tester" with
properties {name:"Desktop1"}
--> folder "Desktop1" of folder "Tester" of folder "Desktop" of
folder "shane" of folder "Users" of startup disk
get folder "Desktop1" of folder "Tester" of folder "Desktop" of folder
"shane" of folder "Users" of startup disk
--> alias "Macintosh HD:Users:shane:Desktop:Tester:Desktop1:"
end tell
So you're sending three separate events every time. Cutting out asking for
the same container name every time will help, and don't ask for an alias if
you don't need one.
But again, if time matters you're better off not talking to the Finder.
Here's your script using a simple "do shell script" instead:
set temp to (path to desktop)
set temp2 to temp & "Tester" as text
set filePath to temp2 & "Untitled 2.pages"
set temptime to current date
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set folderName to text item -2 of filePath
set AppleScript's text item delimiters to oldDelims
repeat with x from 1 to 1000
set dirpath to quoted form of POSIX path of (temp2 & ":" & folderName &
x)
do shell script "mkdir " & dirpath
end repeat
display dialog (((current date) - (temptime)))
OMM that takes 7 seconds. And any moment someone else will pipe in with a
quicker version.
--
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