How can I create a new folder within a nested folder hierarchy using Finder?

5,768

Solution 1

One (very unrecommended) option would be to assign a shortcut to an AppleScript like this. There's an open bug in 10.7 that makes the script more or less unusable.

tell application "Finder"
    if insertion location as alias is desktop as alias or current view of Finder window 1 is in {icon view, column view} or selection is {} then
        tell application "System Events" to tell process "Finder"
            click menu item "New Folder" of menu 1 of menu bar item "File" of menu bar 1
        end tell
        return
    end if
    tell application "System Events" to key code 124 -- right arrow
    set p to item 1 of (get selection)
    try
        set f to make new folder at p
    on error
        set f to make new folder at container of p
    end try
    set selection to f
end tell
tell application "System Events" to keystroke return

Solution 2

Open the folder where you want to create a new folder with ⌘O and then create what you want.

Solution 3

O is nice to get started.

N will create the new folder.

[ will bring you back.

This is not optimal but at least you do not have to use the mouse.

Solution 4

I'm replacing my original incorrect post with this...

It took me ages to understand what was going on with this.

The trick to understanding what is going on here is to note the name of the folder in the title bar. In macOS, whenever you create a folder, that is the folder that the new folder will be created under.

That is why Thomas' post works, or in column mode as you click each folder the folder in the title bar changes and Command + Shift + N will create the folder correctly.

Share:
5,768

Related videos on Youtube

slhck
Author by

slhck

Updated on September 18, 2022

Comments

  • slhck
    slhck almost 2 years

    Here's a thing that's been annoying me for a long time: Using OS X 10.6, when you navigate through folders, expanding them to see their content, you sometimes want to create a new folder at the bottom of the file hierarchy.

    Consider this example:

    some
    └── nested
        └── folder
    

    Now, having selected "folder", pressing N results in the new folder being created at the top of the visible hierarchy, i.e. the currently open Finder element (which in my case is "test"):

    ├── some
    │   └── nested
    │       └── folder
    └── untitled folder
    

    This is not what I need. I will manually have to move the "untitled folder" to its target parent, which is hard to do if you 1) don't want use your mouse, 2) can't CutPaste a folder like in Windows and 3) the current folder contains a lot of elements.

    What I need is:

    some
    └── nested
        └── folder
            └── untitled folder
    

    The new folder should be created in the folder that I currently selected (i.e. "folder").

    Note that:

    • I want this to be done with a keyboard shortcut. I don't use the mouse that often.
    • I don't want to use any other Finder view (e.g. Columns)

    Is there any way this could be achieved?


    I know the Automator action "New Folder", but it copies the selected Finder elements into the target folder, and it's inserted at the wrong level. For example, selecting "folder", the result will be something like:

    └── some
        └── nested
            ├── folder
            └── untitled folder
                └── folder
    
    • Admin
      Admin over 9 years
      Right on! It's ridiculous that the folder gets created at the top of the tree instead of under the selected folder! I'm on yosemite and it still does this.
    • Admin
      Admin over 2 years
      I just switched back to MacOS after about 4 years and just had this exact issue 10 years after the OP LMFAO - no idea how I did this 4 years ago. Seems very broken however?! This is of course trivial in Windows as there's a tree structure on the left.
    • Admin
      Admin over 2 years
      The way I 'fixed' this in the end was to use column view - much easier.
  • slhck
    slhck almost 13 years
    Your script had this result, but I changed it to do what I need (minor thing). Works as expected though :)
  • brevno
    brevno almost 13 years
    I modified the script so that it tries to create the new folder inside item 1 of (get selection) first.
  • ruslaniv
    ruslaniv almost 9 years
    Yes, that will work but only if you have a folder selected. If you've already selected a file within that folder, the first shortcut will just open that file.