Re: Removable Disks (wrapping code)
Re: Removable Disks (wrapping code)
- Subject: Re: Removable Disks (wrapping code)
- From: Nigel Garvey <email@hidden>
- Date: Tue, 11 Nov 2003 14:07:08 +0000
email@hidden (Christopher Rosado) wrote on Mon, 10 Nov 2003 20:39:48
-0500:
>
I'll be using this script with 10.3...
>
I wasn't sure how to accomplish what Jay had done with my If statement
>
replacement. Very clean! Far more efficient than what I was doing.
>
On Nov 10, 2003, at 6:11 PM, Christopher Stone wrote:
>
> If you're using a Mac OS X box, then Jay's code is very inefficient.
>
>
>
> For instance:
>
>
>
> set folderName to do shell script "date +'%Y/%d/%m folder'"
>
>
>
> Beats hell out of if...if...if...
I suppose it depends on what you mean by "beats the hell out of". In
terms of source code brevity, the shell script wins hands down. In terms
of machine efficiency, the sub-optimal "if" code that Chris R posted
yesterday - even though it includes fourteen 'current date' calls, twelve
month extractions, and two or three lists - is still over twice as fast
on my machine.
For sheer whoosh, I'd use an efficient AppleScript rather than a shell
script to create the folder name from the date - and a shell script
rather than the Finder to create the folder if necessary:
set today to current date
set {year:y, day:d} to today
copy today to b
set b's month to January
tell (y * 10000 + (b - 2500000 - today) div -2500000 * 100 + d) as
string
set folderName to text 1 thru 4 & "-" & text 5 thru 6 & "-" & text 7
thru 8
end tell
do shell script ("mkdir -p " & quoted form of POSIX path of ((path to
desktop as string) & folderName))
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.