Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I wanted to know if there is way to set keyboard shortcuts to make new files in Finder. For example, by default, you can create a new folder using CMD+Shift+N. Is there a keyboard shortcut to create a new text file? I'm a programmer so this would be extremely useful

I would also be interested in creating other file type using keyboard shortcuts.

I have attempted to use automator but I'm finding it quite confusing and I'm not sure how I would connect a keyboard shortcut to it.

share|improve this question

6 Answers 6

up vote 8 down vote accepted

Well, here you go with an AppleScript for that. To Use it, Open Automator, create a Service, set the input to "no input", Drag and Drop the "Execute AppleScript" Workflow Element onto the grey space, save the workflow;

Go to Settings -> Keyboard -> Shortcuts -> Services, Assign a Shortcut to it.

The Shortcut may not work, if it is assigned to an Apple-Intern Shortcut already. So be creative on choosing a new one.

try
  tell application "Finder" to set the this_folder ¬
   to (folder of the front window) as alias
on error -- no open folder windows
  set the this_folder to path to desktop folder as alias
end try

set thefilename to text returned of (display dialog ¬
 "Create file named:" default answer "filename.txt")
set thefullpath to POSIX path of this_folder & thefilename
do shell script "touch \"" & thefullpath & "\""
share|improve this answer
1  
I don't understand how to set at shortcut to this specific script through the services tab –  himion0 May 5 at 12:25
    
I added a more detailed way on how to add this script as a shortcut. –  YoshiBotX May 5 at 12:27
    
Now it should work with empty folders also. At least it works for me. You can write your template file inside the script "filename.txt". –  YoshiBotX May 5 at 12:32

You can create an Automator Service yourself — it is rather simple to do. Then you can assign a keyboard shortcut to it so that you don't need to activate the service through the services menu (which you can do anyway).

Open Automator and select Service as the type of new document.

Set the service to receive no input in Finder.app and add the New TextEdit Document action to the workflow.

Workflow

Save the service, then open System Preferences → Keyboard → Shortcuts → Services where you will find the service listed under General with the name that you gave for the service when you saved it.

Services

Add a keyboard shortcut to the service by selecting the service then clicking 'add shortcut'.

Here you might have some problems if the shortcut is used already. So get creative to make one that works for you.

share|improve this answer

This is a repost of a post that I made last year. I have had good experience with the following.

There are two useful utilities that you can download and install that will enable you to create a new text file (or RTF file) in a currently-open folder that you are viewing using the Finder.

The utilities are called NewTextFileHere and NewRTFHere and can be downloaded from

http://mac.softpedia.com/developer/Jonas-Wisser-37498.html

Icons for either of these apps can then be included on all of your Finder windows.

share|improve this answer

Just what I'd been looking for, Richard Fuhr. Thanks for this.

One note: that URL's link for the NewTextFileHere seems to load to an empty page. But I did a search and found the app here: http://mac.softpedia.com/progDownload/NewTextFileHere-Download-70374.html

share|improve this answer

You could also assign a shortcut to a script like this:

tell application "Finder"
    set selection to make new file at (get insertion location)
end tell

The insertion location is either the target of the frontmost Finder window or the desktop.

share|improve this answer

open terminal and type touch filename

share|improve this answer
    
you lost me here? what does that do? –  Buscar웃 May 5 at 14:40
3  
Could you expand on how you would add a keyboard shortcut to this command? (@Buscar See touch) –  grgarside May 5 at 14:40
    
well if you have PathFinder - that is really a great option ;D –  YoshiBotX May 5 at 22:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.