Search code examples
applescriptautomator

Select all folders with Automator


How can I create a custom Automator command to simply select all folders within a folder?

If I runned the action it would look like this.

Thanks! Nicolas


Solution

  • Add:

    • Get Folder Contents (this will get all items in the given input folder)
    • Filter Finder Items
      • and set Kind is Folder

    For testing add Reveal Finder Items at the end. Screenshot:

    enter image description here

    The result will be the list of folders in the given input folder. This is simple but slow solution. (The Get Folder Contents action is very slow.


    The fast solution could be written using some scripting. Actions:

    • Run Shell Script (set the Pass Input: as arguments) and add the following script:
    for f in "$@"
    do
        find "$f" -maxdepth 1 -mindepth 1 -type d -print
    done
    

    The result is as above, just much-much faster.

    enter image description here