Create New File in Finder 2

Posted April 16th, 2012

Over the weekend I wrote an extension for Alfred to solve the problem of not being able to create new files easily from the Mac OS Finder.

After I had written what was a very rudementary script to solve the problem, I posted it to my blog (the one you’re reading now). Within a couple of hours I had over 500 views to the post, and a few comments. Thanks to everyone who took the time to find me on twitter or post a comment.

One of my commenters was Chris Kalafarski (farski). He had re-written my script using Ruby. This had the advantage of running a little faster than mine, and he iterated on it further by adding a filename parameter, and even a system to use predefined templates for the new files. I gave the script a spin, and was delighted. It was a far better solution to my problem.

So I took the liberty of adding a basic help system and packaging the Alfred script as one you can download and install. If you want you can download the raw Ruby script from Chris’ Github account here, or just download the .alfredextension below.

Many thanks to Chris for making my life easier. Again, I hope this is as useful to you as it is to me.

Download v2.0 (12kb)

 

How to use the extension

To create new files with a desired name

Simply load the folder you would like the new file to appear in, in the Finder. Then call up Alfred, and type “new “. You can now enter a new filename to be used for your new file. E.g. “index.html”. Your new file will be created in the folder for you instantly.

To add a template

Templates are used for new files of a specific filetype. If for example you want all new HTML files to have a basic HTML structure prefilled, you can add this to your templates directory.

To add a template, you must first create a new template folder inside the extensions folder. To get the extensions folder, right click on the extension name in the Alfred Preferences, and click Show In Finder.

Create the templates folder, and then add your template file inside, using both the name and extension as the filename.

Now when you add a new file to any folder, your template will automatically be used if the filetype matches.

Other things to note

You can create a file, by simply pressing return after typing “new “. This will create an “untitled.txt” file, to be renamed by you later.

Basic help can also be called up using in a growl message, using either ‘help’ or ‘?’ commands. E.g. “new help”.

  • Pingback: Create New File in Finder. A script for Alfred App | Ian Isted

  • Thiago A.

    Great extension, thank you!

    • http://ianisted.co.uk/ Ian Isted

      You’re quite welcome. The real praise goes to Chris for making the new script. It is so much better than the one I came up with. A pleasure to use.

  • Chris Gruggen

    Great extension. Any support for Path Finder soon though? 

    • http://ianisted.co.uk/ Ian Isted

      Not yet, but I’d be happy to look into it for you. Sorry for the late reply.

  • http://www.facebook.com/brandon.reynolds.779 Brandon Reynolds

    Can you update this script for the new AlfredV2? This was my goto script for the longest time.

    • http://ianisted.co.uk/ Ian Isted

      Hi Brandon,

      It’s good to know you got as much use out of it as me. I am going to rewrite the script for the Alfred 2. I’m afraid I’ve been quite swamped with work, so I haven’t done it yet.

      However I’m confident I can have it some pretty quickly. I’ll update as soon as it’s released.

      Thanks
      Ian

      • http://www.facebook.com/brandon.reynolds.779 Brandon Reynolds

        Great! Thanks!

      • http://ianisted.co.uk/ Ian Isted
      • http://www.facebook.com/brandon.reynolds.779 Brandon Reynolds

        Thanks! Much Appreciated!

  • http://ianisted.co.uk/ Ian Isted

    I’ve updated this Extension to work with new Alfred Workflows. You can download it here! http://ianisted.co.uk/new-finder-file-alfred-2

  • Viktor

    added the line
    print “#{path}”

    just before the ‘end’. And output to notification center, So I can see the path in the notification.

    Thanks great workflow.

  • Pingback: Create New File in Finder with Alfred | Stuff