114

In windows I right click and then there is an option to create a text file.

How to do so in mac?

  • 1
    This issue has 211,723 views as of 10-23-2018 and, 5 years + 7 months later and Apple has not addressed it yet. I understand it could be a matter of principle, but many people coming from Windows struggles with it and a lot of time is wasted trying to learn the "different" way of opening the app then saving the work as a file. One Apple developer could save 200,000 newbies and more... – Ricardo Oct 24 '18 at 4:02
  • (not to mention that this issue is actually really older, this question is asked over and over and there are a lot of creative solutions, scripts, etc) – Ricardo Oct 24 '18 at 4:04

19 Answers 19

13

If you have the Finder window open, use Spotlight to open TextEdit. When you're ready to save the file, option+drag the text file icon from the title bar of TextEdit into the Finder window where you want to save it.

  • 8
    1. The title bar of TextEdit does not have a text file icon. 2. TextEdit does not offer to save it as a simple txt file. Only RTF, .html, odt, word and webarchive is possible – bitbonk Jun 21 '17 at 20:26
  • 1
    1. The title bar icon appears shortly after creating the new document. 2. Textedit can be configured to use plain text by default. This means new files will be saved as txt not rtf. 3. I had to option+drag to get it to move the file to the desired location, rather than create a shortcut. – Samuel Coskey Aug 25 '17 at 20:28
  • 1
    This works as long as you set a file name first by clicking the downwards pointing caret at the right hand side of "Untitled". Just set the name, leave "where" as it is, and you are able to drag. – Jasper de Vries Jan 1 '18 at 18:09
  • 2
    As of High Sierra, the easiest way to save as text is to select "Format" > "Make Plain Text" before saving a new file. – tripleee Feb 2 '18 at 8:16
58

You can also do this in Terminal. Go to the directory where you want to create the file, then run the following:

touch file.txt

Or redirect 'nothing' to a text file

> file.txt
  • 2
    any easy way to go the directory that I want? Unlike in windows I can't even copy that directory as text – user4951 Mar 5 '13 at 14:57
  • 7
    In Terminal, you can type cd, then a space, then drag a folder onto the Terminal window and press Return to go to that folder. – Kirk McElhearn Mar 5 '13 at 15:53
  • 2
    In 10.8 and later you can also drag the folder on a Terminal window while holding command. Or if you copy the folder, ⌘V inserts its path in Terminal. – Lri Mar 5 '13 at 16:40
  • 25
    None are convenience for users. For a text file, I have to open up a terminal type a command and drag and drop then type another command! Come on! – malhobayyeb Mar 17 '15 at 5:16
  • You can always use the full path on the command line, and generally don't need to cd (though it can be convenient). touch "$HOME"/Documents/fnord.txt will create fnord.txt in your Documents folder regardless of your current directory. touch /etc/moo will create a file in the system directory /etc (provided you have the privileges to create a file there, which you actually probably don't have). touch path/to/foo will create foo in the directory path/to which is the subdirectory to of the subdirectory path of the current directory. – tripleee Feb 2 '18 at 8:19
14

There's two ways to do this, the easiest is the first option;

  1. Open TextEdit and type whatever you need into it then save it to the location you want the file to live.

    You can open TextEdit quickly by invoking Spotlight and being typing Tex..., you should see the top hit is the app you want so you can just press enter to open it.

  2. This is more involved and will require you to create an AppleScript. The contents of the script needs to be:

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

Export the script as an Application somewhere safe and make sure you tick Run Only when saving it. Then drag the resulting file to the toolbar in Finder

This will then allow you to create a blank text file in what ever window you're viewing in Finder called untitled which you can then double click to edit in TextEdit

The Ultimate Beginner’s Guide To AppleScript, is good if you want to know more about AppleScript.

  • 1
    @apricot Mavericks and above requires that you hold Command+Option while dragging in order to be able to drag it to the Finder toolbar. Be sure to export the script as an Application first as mentioned above (File > Export). – Matt Browne Jan 5 '17 at 16:19
  • Hm, for me the script creates new untitled files in Applications folder and not in the current folder I'm in. – JustAMartin Jan 18 '17 at 12:28
  • For the AppleScript method, I need to right click a folder for the Service show. How can I show it by just right clicking empty space in Finder? – Ehtesham Hasan Sep 27 '17 at 13:49
  • Dragging it to the toolbar does nothing for me. Can you post a gif or something? – gman Nov 12 '18 at 4:52
13

Here is my workaround:

  1. Do this once, create an empty text file in your desktop to serve as template.

  2. Opt/Alt-drag this file to the folder to make a copy.

  • 1
    This solution is great -- my small tweak: put the blank template in your Downloads folder to keep the Desktop cleaner. Then click the Downloads folder in your Dock and option-drag as you said. – spinup Feb 1 '18 at 1:26
13

Check my answer at - SuperUser.

NOTE: After the introduction of SIP, this app does not work unless you disable it. Read more on how to do it, but it is ill-advised.

Try XtraFinder.

This app is just great, solved all my basic needs after switching from a windows platform like adding "New File" in context menu and finder toolbar, etc. Some of the features as listed on their website are -

XtraFinder add Tabs and features to Mac Finder.

• Tabs & Dual Panel.

• Arrange folders on top.

• Cut & Paste.

• Global hotkeys.

• "Copy Path", "Show Hidden Items", "Hide Desktop", "Refresh", "New File", "Copy to", "Move to", "New Terminal Here", "Make Symbolic Link", "Contents", "Attributes", … .

• Legacy label for OSX 10.9 & 10.10. Light text on dark background. Transparent window.

• Colorful icons in Sidebar.

• Size of selected items in Status Bar.

• Automatically adjust width of columns.

• Press Enter or Return to open selection.

• Display folder item count in List view.

• Middle-click to open folder in new window or new tab.

• Much more.

I use this app with OS X 10.9.5 and did not encounter any issues with it. It has native os x icon style which looks good on retina screens also. Here is a screenshot of my finder toolbar -

Finder Toolbar

Ps. this app is also free!

  • This no longer works on OSX.11 without disabling integrity protection which even the software author discourages. – hawkeye Oct 22 '16 at 3:50
9

The simplest version does not require a file or folder to be selected, and adds a keyboard shortcut of your choice.

Part 1: Create a new Quick Action (was Service)

In Automator, create a new Quick Action:

enter image description here

From the left site, click Utilities then drag "Run Applescript" over to the right panel.

Change the two pulldown menus at the top of the right panel to read:

Service receives no input in Finder.app

Replace ALL the purple script with:

tell application "Finder"
    set txt to make new file at (the target of the front window) as alias with properties {name:"empty.txt"}
    select txt
end tell

Save the Service as "New Empty Text File" (.workflow extension will be added automatically).

This service is now available under the Finder menu in the Finder.

Part 2: Create a Keyboard Shortcut

Under System Preferences › Keyboard › Shortcuts › Services, scroll down to General (it's at the end).

You will see New Empty Text File listed with "none" as the shortcut.

Click on none and type the shortcut of your choice (I used cmd alt N):

enter image description here

You can now type your shortcut in the Finder whenever you want to create a new, empty, text document.

Thanks to Syreeni, whose answer made this possible, and to RoG (comment below) who contributed the line that automatically selects the new file.

  • 1
    If "untitled.txt" already exists then the service throws an error message you have to then deal with. Suggest you code in some error handling. – user3439894 Feb 2 '18 at 22:33
  • 1
    You can simply delete " with properties {name:"untitled.txt"}" and it will create sequential empty files. I left it in because I wanted my answer to be as brief as possible and personally, if there's already an empty file, I'd rather be alerted and use it than create a second one. – Andrew Swift Feb 5 '18 at 14:03
  • 2
    I added a second applescript line tell application "Finder" to select the file "untitled.txt" so that I can easily find the new file, and hit the return key to rename it. – RoG Sep 29 '18 at 18:02
  • Greate idea, I added it to answer and credited you at the bottom. – Andrew Swift Sep 30 '18 at 12:16
  • Great idea, but I would like to use it to create a file on the Desktop. It works everywhere except the Desktop, where it says there is an error (without specifying what error), do you have any idea about why this happens? – Kubuntuer82 Mar 20 at 11:36
7

How to create as an Automator Service (OS X El Capitan 10.11.5):

  • Open Automator and select File > New > Service.

  • Next, choose Folders from the drop-down menu Service receives selected ...

  • In the Actions menu search for and add Run AppleSript or drag & drop it from the Utilities category.

  • Copy and paste this script into the Run AppleScript action:

    tell application "Finder" to make new file at (the target of the front window) as alias with properties {name:"untitled.txt"}
    
  • Save the service as New Text File or similar.

You should now be able to right-click on a folder and find Services > New Text File.

Note: You'll get an error if you try to add a second untitled.txt to the same folder.

  • If you don't specify name of the file, the service would number the files like so untitled, then untitled 2 and so on wuthout causing an error. – Zajo Oct 5 '16 at 10:27
  • This works pretty well thanks. Is there a way to add two features? Can the new file be saved directly as 'newfile.txt'? At the moment I get the Services option only when I right click on a Folder Icon, is there a way to get that option while clicking on a Finder window? – Andrea Jul 26 '17 at 11:20
  • Any way to make it so that it doesn't require right clicking a folder? I was hoping I could do this by just right clicking on empty space in a Finder window. – Ehtesham Hasan Sep 27 '17 at 13:38
  • 1
    @EhteshamHasan Unfortunately the Finder doesn't display the services menu (or anything this can hook into 😕) when not selecting any input files or folders. – Kilian Koeltzsch Oct 11 '17 at 9:32
  • EhteshamHasan and Andrea Di Biagio, see my answer below. You don't have to select a file folder for it to work, and the service is available under the Finder menu even when nothing is selected. – Andrew Swift Feb 2 '18 at 20:32
4

On el capitan (and probably others) the best solution I found is to download the script here:

http://www.codium.co.nz/touch%5Fhere%5Fapp/

Then open a finder window, right click on the top bar > customize toolbar and put the script on your toolbar.

Now you have it in one click for all your finder windows, and it will prompt you what file name you want instead of just creating a dumb file name.

UPDATE: I just made a repo for that, which exposes the source code: https://github.com/lingtalfi/newFileWithPrompt

  • When I enter the name of a file and click OK, I get You don't have permission to create a file here – JustAMartin Jan 18 '17 at 12:35
  • 1
    @JustAMartin Any method of creating a file will fail if you don't have the required permissions. – tripleee Feb 2 '18 at 8:27
  • But I can save a file in the same folder when using a text editor. It's just that script that failed with the error, but other programs allow to save there. – JustAMartin Feb 2 '18 at 11:20
  • Thanks for this! By far the best solution I ran into after much googling. Such a basic function that MacOS doesn't support. – davidfrancis Aug 21 '18 at 10:09
3

Here's my script for creating new files from a store of templates.

I run it with FastScripts using a keyboard shortcut, but you can save it to an applet and put it in the menu bar, create an automator action, etc.

-ccs

----------------------------------------------------------------------------
--       Author: Christopher Stone 
--      Created: 2012-10-26 : 01:27
--     Modified: 2012-10-26 : 18:26
--  Application: Finder
--      Purpose: Create a new file from a file-type list in the front Finder window using
--             : template files stored in a folder.
-- Dependencies: Template files provided by the user.
--    Templates: Auto-creates a Text template - others are for the user to supply.
----------------------------------------------------------------------------

try

  try
    set templateFolderPath to ((path to application support from user domain as text) & "Script_Support:New_File_Here!:")
    set templateFolder to alias templateFolderPath
  on error
    set newFilesHereFolder to quoted form of (POSIX path of templateFolderPath)
    set textTemplate to newFilesHereFolder & "Text_Template.txt"
    do shell script "mkdir -p " & newFilesHereFolder & ";
     touch " & textTemplate & ";
     open -R " & textTemplate
    return
  end try

  tell application "Finder"
    if front window exists then
      set winTarget to target of front window as alias
      set fileTemplateList to name of files of templateFolder

      tell me to set fileType to choose from list fileTemplateList with title "New_File_Here! Templates" with prompt ¬
        "Pick One or More:" default items {get item 1 of fileTemplateList} with multiple selections allowed

      if fileType ≠ false then
        set AppleScript's text item delimiters to (return & templateFolderPath)
        set itemsToCopy to paragraphs of ((templateFolder as text) & fileType)

        repeat with i in itemsToCopy
          set i's contents to i as alias
        end repeat

        set copiedFiles to duplicate itemsToCopy to winTarget
        select copiedFiles
      end if

    else
      error "No windows open in Finder!"
    end if
  end tell

on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try

----------------------------------------------------------------------------
  • 1
    This solution is great if you're got Alfred with the powerpack so you can just use a hotkey over a finder window – David Oct 7 '15 at 21:05
2

I use PathFinder as a replacement for Finder and it includes this in its right-click context menu. It is prboably too expensive a solution just for this but if you want to have a better Finder for other reasons as well.

2

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.

  • Or use "stationary Pad" in the finder, which does this, and is a built in OS function. – stuffe Dec 19 '13 at 14:58
2

This article from MacWorld indicates how to create a service that creates a new text file.

2

You can use the Easy New File Creator, a free app for macOS.

Using Easy New File Creator, a finder extension you can add create new file functionality in the Finder context menu. You can customise the file name and extension for file to be created.

2

On the mac in finder, select a .txt file, hold option and drag it to make a copy, then edit it as usual.

2

There's a very simple method using touch command in Automator:

Create a new service in Automator

Create a Service in Automator

Set it to receive selected "files or folders" in Finder

enter image description here

Add a Run Shell Script with Pass input "as arguments" and paste this code into the shell:

for d in "$@"; do
cd "$d"
touch untitled.txt
done

paste code

Save it.

Done!


And if you want to add a keyboard shortcut to it, go to System Preferences > Keyboard

add shortcut

Enjoy ^^

1

I just downloaded New File menu (2$) from the app store and it seems to work fine.

0

This is one of the many things that BetterTouchTool does for me. It has a pre-defined action "Create New File in Current Folder" for this.

enter image description here

0

On macOS, applications create files, not the Finder. So to create a file (or a text one), you need to use an App creating one; for example TextEdit, BBEdit, TextWrangler, etc.

To save the file, you call 'File > Save'. This is standard on macOS and all apps have it.

'File > Save' offers a dialogue for you to enter a name to your file and to choose the folder in which to save it to.

To save in a specific folder without the need of navigating to it previously:

  • open the folder in which you want to save your (text) file in the Finder
  • while editing your file… call 'File > Save' and drag the folder icon from the open window in Finder to the 'Where' popup of the Save dialogue: enter image description here This changes the location where the file will be saved.
  • click on 'Save'.

If the file was already saved, to move a file you can call 'File > Move' and proceed similar to above.

-1

My method to make an empty text file is crude but simpler:

Simply create a new text file in TextEdit, then save as Rich Text Format "whatever.rtf"

Then press cmd-shift-T to convert it to plain text.

Say yes when the dialog box pops up asking to confirm change.

And you're done.

P.S. Once you have changed it to a .txt file. You can then edit it with any text editor and save it and it will remain a .txt file.

  • This doesn't actually work. Renaming the file doesn't turn it into a different format, and TextEdit will still open it as RTF, regardless of the extension. – tripleee Feb 2 '18 at 8:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .