Create New File with Alfred App and Hotkeys

I wanted an easy way to create new files with the ever-awesome Alfred App.

First attempt (which is still pretty neat) is to use the silent terminal commands option (requires at least v0.9 and the PowerPack).

touch /Users/YOUR_HOME_FOLDER/Desktop/unnamed.txt

Make sure to tick the “silent” box after you create the shortcut. With this, the shortcut “newtxt” creates a txt file on my desktop called “unnamed.txt” – I have a second version which accepts a query to let me name the file when I create it:

touch /Users/YOUR_HOME_FOLDER/Desktop/{query}

A little fancier

Keep in mind, I’m not an AppleScript expert, so all I did was copy the script from somewhere else and plug it in….

This method will create a text file in the active Finder window.

Step 1: create a file called newfile.sh (perhaps using the above method?)

Step 2: open that file and paste this in it and hit Compile:

tell application "Finder" to make new file at (the target of the front window) as alias

Step 3: go to Save As…, choose Script Bundle (I also checked “Run Only” but I don’t think that really matters here). I think you can also just rename your file with a .scptd extension.

That should have created a file called newfile.scptd (feel free to rename it)

Step 4: In Alfred’s preferences, go to Global Hotkeys, and add new

Step 5: set up a key combo (I’m currently using ctrl + alt + cmd + n) and browse for the .scptd file you just created.

Step 6: test it!

Hopefully everything should work smoothly.

Again, I’m not well versed with AppleScript, so chances are I can’t answer any questions you may have.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: