Here’s a script you can use for this. It works both in list and column views. The renaming part doesn’t work properly in icon and gallery views, which can be annoying.
To use it with a shortcurt, I exported it as an application from Script Editor and set a shortcut to that application in Butler. I used the standard Finder shortcut for “New folder”, since I don’t need icon and gallery views, but you may prefer something different to still be able to use the regular shortcut. Note that the app must be granted accessibility permissions (System Preferences › Security › Confidentiality).
You may want to adjust the delays to your system’s reactivity, as they can be annoying if you’re used to type the new folder’s name quickly after it’s created. Hoewever, if they’re too low, renaming won’t work.
-- By Philippe-André Lorin
-- 2020-12-13
-- macOS 10.14.4
-- See https://apple.stackexchange.com/a/408759/185198
-- Create folder inside currently selected folder
-- or at the same level as currently selected file
try
tell application "Finder"
set selectedItems to selection
set currentPath to ((the first item of the selectedItems) as alias)
-- Set parent path for future new folder
if (currentPath as string) ends with ":" then
-- It’s a folder
set the parentPath to currentPath
else
-- It’s a file
set {savedDelimiters, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set the parentPath to (text items 1 thru -2 of (currentPath as string)) as string
set AppleScript's text item delimiters to savedDelimiters
end if
-- Create new folder
my createFolder(parentPath)
end tell
on error -- No folder or file is selected
tell application "Finder"
set the currentPath to (folder of the front window as alias)
my createFolder(currentPath)
end tell
end try
on createFolder(folderLocation)
tell application "Finder"
-- Make new folder
set thisFolder to make new folder at folderLocation
delay 0.2 -- N.B. Without delays, the following operations sometimes fail.
-- Select new folder
set selection to thisFolder
delay 0.2
-- Call “Rename” menu in Finder
activate
tell application "System Events"
tell application "System Events"
tell process "Finder"
tell menu bar 1
-- N.B. The following must be adjusted to the Finder’s language settings
tell menu bar item "File"
tell menu "File"
click menu item "Rename"
end tell
end tell
end tell
end tell
end tell
end tell
-- Return
return thisFolder
end tell
end createFolder
Note. This script was adapted from the first script on this page: http://hints.macworld.com/article.php?story=20081119025327978