Home › Blog › How to Create a New File on macOS Using Snippety
· 4 min read

How to Create a New File on macOS Using Snippety

Finder has "New Folder" but still no "New File". One snippet can fix that: activate the snippet, type a name, and an empty text file appears in the Finder window you are looking at.

The usual routine is: open a text editor, hit Save, then hunt through the save dialog for the folder that was already open in front of you. Or switch to Terminal, cd into the right place, and touch it.

Snippety can combine that into a single snippet.

The snippet

Create a snippet with a single Command Line Script placeholder:

{@script|TextField|touch "$(osascript -e 'tell application "Finder" to POSIX path of (target of front window as alias)')%@.txt"|NO@}

Give it a name you will remember, something like New File, and that is the whole setup.

Creating a file in Finder

What the command actually does

Three pieces, from the inside out:

The two parameters around the script matter as much as the script itself. The input mode is TextField, which is what makes Snippety stop and ask you for the file name when you expand the snippet. Escaping is set to NO, because %@ already sits inside a quoted string; leaving escaping on would wrap it in a second set of quotes and put them in the file name. Names with spaces still work fine.

One thing worth knowing: touch prints nothing, so the snippet expands to an empty string. Nothing is typed into the app you triggered it from. You can fire it from your editor, your browser, or Slack, and the only visible result is a new file appearing in Finder.

Standalone version: works as is

If you use the standalone build of Snippety, paste the snippet in and you are done. The app is not sandboxed, so it can talk to Finder and write to any folder you have access to.

App Store version: install Snippety Helper first

The App Store build is sandboxed, and that changes things. Sandboxed apps can only write inside ~/Downloads, and they cannot send Apple Events to Finder. Both halves of this snippet need exactly what the sandbox blocks, so it will fail on its own.

The fix is Snippety Helper, a small background script that runs commands outside the sandbox and hands the output back. Install it from Terminal:

cd ~/Downloads && /bin/bash -c "$(curl -fsSL https://snippety.app/SnippetyHelper-Installer.sh)"

Then start it, and set it to launch at login if you want the snippet to keep working after a restart. The documentation covers both the Automator route and a Launch Agent.

With the helper running, wrap the command in snippety-helper. The quoting has to flip around, since the outer argument now takes the single quotes:

{@script|TextField|snippety-helper 'touch "$(osascript -e "tell application \"Finder\" to POSIX path of (target of front window as alias)")%@.txt"'|NO@}

Same behaviour, one extra moving part. If you would rather not run a background helper, the standalone build is the simpler answer.

Variations

Once the pattern is there, the rest is just editing the command:

{@script|TextField|bash -c 'f="$(osascript -e '\''tell application "Finder" to POSIX path of (target of front window as alias)'\'' )%@.txt"; touch "$f"; open "$f"'|NO@}

The Command Line Script placeholder is the general-purpose escape hatch in Snippety: anything you can do in a shell, you can bind to a keyword. Creating a file is just the smallest useful example. See the placeholder reference for what else it composes with, or Snippety for developers for more in this direction.

Ready to type less and do more?

Snippety is a native text expander for Mac, iPhone, and iPad. Free to start — one-time purchase available.

Download for Mac See pricing

Frequently asked questions

Why is there no "New File" option in Finder?

Apple has never shipped one. Finder can create new folders from the right-click menu, but creating an empty document is left to individual apps and their Save dialogs. Automation tools like Snippety, Shortcuts, or a Finder service are the usual workarounds.

What happens if no Finder window is open?

The AppleScript has no front window to read, so it returns an error and no file is created. Open or click a Finder window first, then trigger the snippet.

Does this work in the App Store version of Snippety?

Yes, but it needs Snippety Helper. The App Store build is sandboxed, so it cannot write outside ~/Downloads or control Finder. Snippety Helper runs the command outside the sandbox and returns the result. The standalone build needs no extra setup.

Does it work on iPhone or iPad?

No. The Command Line Script placeholder is macOS only, because iOS does not give apps access to a shell. The snippet will not do anything on an iPhone or iPad.

Can I create the file with content instead of an empty one?

Yes. Replace touch with a redirect, for example echo "some text" > "$path", or call a template file. Anything the shell can do, the placeholder can run.

← Back to all articles