Native Mac Way to Create Text Files via Finder Menu?

NewFileClick has been convenient. Especially when I need to create new JS / C++ files. Don’t think it works with cloud folders

Hi and welcome.

What does it mean to create a “new JS …” file? Is it just a text file with the extension .js? Or is it more of a file template, perhaps user definable? It is not clear from the website or AppStore descriptions.

Thanks.

How long I struggled to create the best solution for this! Ultimately, I created a macOS Shortcut called “Create new file here”, which I launch via right-click → Quick Actions.

The Shortcut then prompts for a filename, which defaults to untitled.txt.

The file is created using a Bash script (touch command). If a file with that name already exists, it will append a number afterward.

Here is the Shortcut with the Bash script.

Make sure that the Shortcut is set-up properly to run in Finder and via the Services Menu.

I hope that helps someone out there! This took me forever to figure out. Now I use it all the time!

It is easily a feature that should simply be baked into macOS.

4 Likes

It works really well. To go even further, you can create a variant that will use the currently selected folder in the finder, and put the shortcut in the Finder toolbar

To put the shortcut in the toolbar, add shortcut to the dock, go to /Users/<your_user>/Applications where it has been added, hold cmd while you drag the shortcut in the toolbar :slight_smile:

1 Like

Have you tried other right-click enhancer tools such as iBoysoft MagicMenu ? It can help you effortlessly create a new file ( text, pdf, note, excel, word document, etc) via the Finder menu, and move /transfer/quickly access a document etc.

Sindre Sorhus’ Supercharge allows to create any file using the Finder context menu or with a keyboard shortcut, along with a million other things that may or may not be useful to you. And he’s just getting started. At the price, it’s a steal.

4 Likes

I think you could modify it yourself using Karabiner Elements or something similar.

1 Like

I think I might have found the best way to create text files in finder — but not through a context menu. I made this work using the Automator script below, and then making a keyboard shortcut in System Preferences. I’ve detailed the how-to here on my blog.

Here’s the Automator script, use “Run Applescript” and “no-input” and “Finder.app” selected:

on run {input, parameters}
    tell application "Finder"
        if (count of windows) is not 0 then
            set currentFolder to (target of front window) as alias
        else
            set currentFolder to (desktop as alias)
        end if
    end tell
    set folderPath to POSIX path of currentFolder
    if folderPath does not end with "/" then
        set folderPath to folderPath & "/"
    end if
    set fileName to text returned of (display dialog "Enter file name:" default answer "untitled.txt")
    set filePath to folderPath & fileName
    do shell script "touch " & quoted form of filePath
    try
        if fileName starts with "." then
            do shell script "open -a TextEdit " & quoted form of filePath
        else
            do shell script "open " & quoted form of filePath
        end if
    on error errMsg
        display notification "Could not open file automatically: " & errMsg
    end try
    return input
end run
2 Likes

Very nice!

Press ⌥N. Creates a file named untitled.txt with the file name ready to be edited. Then the file gets opened in my quick editor of choice.

Already have a Setapp subscription.

I still love my shortcut (described above). Works great!