Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6223461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:29:38+00:00 2026-05-24T08:29:38+00:00

Update: Solution below Say you have a list of selected items from Finder. Say

  • 0

Update: Solution below


Say you have a list of selected items from Finder. Say there are some files, folders, various bundles, and even some applications included in the selection.

Now say you only want those items that are (in UNIX terms) directories. I.e. you only want items you can cd to in the terminal.

You can check each item’s kind property and see if it equals “Folder”, but that doesn’t work for application bundles or other bundles/packages, though they are in fact “folders” (directories)

If the items are actual file objects (not aliases), you can check each item’s class property… except that doesn’t always work either, since bundles are now “document file” instances, and applications are “application file” instances.

It’s worse if you only have a list of aliases rather than actual file objects, since you can’t check the class property; it’ll always just say “alias”.

The only solutions I can think of, are to either get the POSIX path of each item, and see if it has a trailing forward slash, or to send its path to a script written in a different language, which can check if something’s a directory or not.

Both ideas seem crazy to me. Checking for a trailing forward slash is extremely hacky and fragile, and feeding everything to a different script is complete overkill.


Update: What Asmus suggests below does seem to be the only a good solution, as it seems there’s no way for AppleScript to figure it out on its own:

do shell script "file -b " & filePosixPath

That’ll return the string “directory” for folder, bundles, applications, packages, etc. etc.
But note(!) that for disks, it returns “sticky directory”.

Here’s a generalized function that works pretty well

on isDirectory(someItem) -- someItem is a file reference
    set filePosixPath to quoted form of (POSIX path of (someItem as alias))
    set fileType to (do shell script "file -b " & filePosixPath)
    if fileType ends with "directory" then return true
    return false
end isDirectory
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:29:39+00:00Added an answer on May 24, 2026 at 8:29 am

    There is a simple applescript solution. You can check if something is a “package” using system events.

    tell application "Finder" to set theItems to (selection) as alias list
    
    set canCDItems to {}
    tell application "System Events"
        repeat with anItem in theItems
            if anItem is package folder or kind of anItem is "Folder" or kind of anItem is "Volume" then
                set end of canCDItems to contents of anItem
            end if
        end repeat
    end tell
    return canCDItems
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

** Update I have a solution below, but it's rather manual... if there is
NOTE: I added my new solution at the UPDATE answer below. I try to
Note, I have found the solution to my problem. Please see below. I'm converting
UPDATE: I'm an idiot. Forgot the delegate function. Posted my solution below. Hey, Working
Say I have two JavaBeans Person and Address . If I create a list
Update Solution Found See Bottom of post if interested Seems simple enough and for
I am not interested in any auto update solution, such as ClickOnce or the
[UPDATE] the clean goal runs smoothely all over the projects of the solution, the
Update: I've added an answer that describes my final solution (hint: the single Expr
Update: This question was an epic failure, but here's the working solution. It's based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.