Create New FOLDER In The Frontmost Finder Folder Window

Use Case

As some of you may be aware, the Finder already offers a similar feature. While it works OK, this macro offers the following:

  1. A prompt to enter the folder name, which you can cancel.
  2. Tests for a folder already existing by the same name, and gives you an opportunity to cancel or overwrite.

So this macro may, or may not, be a benefit to you over the Finder feature. You can choose.

MACRO:   Create New FOLDER in Current @Finder Folder

--- VER: 1.2.1    2022/02/18 ---

DOWNLOAD:

Create a New Named FOLDER in the Frontmost Finder Window v1.2.1.kmmacros (16 KB)

Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Create a New Folder in the Current Finder Folder/Window
  • Provides an option to first Trash an existing Folder by the same name.

HOW TO USE:

  1. Open Finder window to the parent folder where you want to create a new sub-folder.
  2. Trigger this macro
  3. Enter Folder Name in KM Prompt

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. :wink:
      .
  • Assign a Trigger to this maro. I prefer ⌘⇧F which will replace/override the Finder shortcut to create new folder.
  • Move this macro to a Macro Group that is only Active when you need this Macro, most likely your "Finder" group.
  • ENABLE this Macro.
    .
  • REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:
    • ALL Actions that are shown in the magenta color

USE AT YOUR OWN RISK

  • While I have given this limited testing, and to the best of my knowledge it will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

1 Like

Hi @JMichaelTX
I'm wondering if you could help me troubleshoot why my Macro isn't working the way I had hoped.

I used your "Create New FOLDER in Current @Finder Folder" macro as a basis for mine. My functionality needs are simpler and doesn't require user input after triggering the macro.

Here's what I want mine to do:

I have a parent folder full of loose .jpg files and some other .jpg files in sub-folders within that parent folder. I would like to select one or more of them (files and/or folders) then trigger a macro that puts everything I selected into a brand new sub-folder named "Studio" within the existing parent folder. Essentially, I don't what selected files/folders leaving the existing parent folder, I just want them put into a new sub-folder within their current location. I hope that makes sense.

The macro I created using your actions as a reference, works fine when I select one or more .jpg files by themselves or with a sibling folder, however, if I select just an empty folder or a folder with other files inside and run the macro, its name gets CHANGED to "Studio" and a new folder named "Studio" is created inside but all the files that were contained within the folder I selected are now siblings to the folder that was previously their parent. So, I end up with:

ParentFolder > Studio > Studio, image1.jpg, image2.jpg, image3.jpg.
What I want is: ParentFolder > Food > Studio > image1.jpg, image2.jpg, image3.jpg
The original structure was: ParentFolder > Food > image1.jpg, image2.jpg, image3.jpg

I think this behavior has something to do with the 'Move or Rename File' action. It's like, if there are files involved in the selection, it will move them and honor all existing file and folder names, however if there are only folders involved in the selection, regardless of whether they contain additional files, they get renamed instead of being moved into a sub-folder.

Is there a solution to this Move or Rename behavior? I don't want it renaming lone folders I select.

Thanks for your attention.

MikeT

Enclose

If I understand your requirements, workflow, and macro correctly (and that's a BIG IF), then:

  1. You create the "Studio" sub-folder, but you never use it (properly):
    image
    .
    image

The "to" field of the File Actions action must be:

If you wish to just move a file, specify an existing folder as the destination of the move.

by "existing folder" it means the full path to an existing folder.

So, I haven't tested this, but I think you need to change the Move Action to field to:
%Variable%CNF__parentPath%Studio

TEST that (using only test files/folders) and let me know if that works. If not, I'll investigate further.

I'm curious about the Action: Get File Type to Variable CBD__DoesFileExist" - are you using that as a method to check for the existence of the folder?

Hey Evan,

Yes. He is.

Although he uses the action-result instead of the variable in his test.

-Chris

Thanks, Chris. I thought so, but I wasn't sure what the advantage was to doing it that way over checking for the existence of the path using an If statement. Clever idea though.

Hey Evan,

Just another example of TMTOWTDI (There's More Than One Way to Do It).

The IF-THEN action with a path-condition is probably a little bit more readable.

-Chris

Thanks a lot for this macro Michael. It helped me making another one, learned something new too.

Just wanted to leave a note here to say thanks, I've been able to use your script

Hello, After some system/software updates/upgrades, this macro is no longer working properly for me. Rather than creating new folders inside the parent folder, now it's creating folders below the parent folder named "parent folder namemyfolder name".

I'm on Catalina 10.15.7 and KM version 10.0.2

Hey Jimmy,

I'm sad to say that @JMichaelTX will not be able to respond...

The Passing of JMichaelTX

JMichaelTX – Unforgettable Generosity With His Time and Knowledge


I have fixed the problem in the macro (see post #1), or so I think. Give it a try, and let me know.

I don't see much value in this macro, because the Finder already has that functionality using Cmd-Shift-N – but YMMV.

-Chris

2 Likes