Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Droplet



On Apr 5, 2006, at 5:52 PM, Mark Siple wrote:

How about this:

set a to {"folder:folder:", "file", "folder:", "folder:folder:file"}
set isfolders to {}
set isfiles to {}
repeat with fileorfolder in a
    if fileorfolder ends with ":" then
        set isfolders to isfolders & fileorfolder
    else
        set isfiles to isfiles & fileorfolder
    end if
end repeat

It's still a loop but it wouldn't need to talk to the Finder so should be
faster. (Well... I think it should be faster!)


There's probably a way to combine "every item" and "ends with" to achieve
this but I can't seem to find it.

Keep in mind that bundled files, such as applications will end with a colon. I don't know if this is an issue or not. For example:


alias "Macintosh HD:Applications:Address Book.app:"

You can also find out if an item is a folder by using the "info for" command, in the Standard Additions...

folder of (info for alias "Macintosh HD:Installer Log.txt")
--> false

folder of (info for alias "Macintosh HD:Applications:Address Book.app:")
--> true

package folder of (info for alias "Macintosh HD:Applications:Address Book.app:")
--> true


You can also use the System Events application to find out if an item is a folder...

tell application "System Events"
	class of disk item "Macintosh HD:Applications:Address Book.app:"
end tell
--> file package

 tell application "System Events"
	class of disk item "Macintosh HD:Applications:"
end tell
--> folder

tell application "System Events"
	class of disk item "Macintosh HD:Installer Log.txt"
end tell
--> file

-Ben

Benjamin S. Waldie
President & CEO
Automated Workflows, LLC
610.935.0652
=============================================
AppleScript and Workflow Automation
Consulting - <http://www.automatedworkflows.com>
AppleScript Info - <http://www.applescriptguru.com>
AppleScript Training - <http://www.applescripttraining.com>
=============================================

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

This email sent to email@hidden
References: 
 >Re: Droplet (From: Mark Siple <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.