315

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

How to do so in mac?

3
  • 31
    It's unreal to me that this is such a difficult task. The below answers work, but good luck explaining them to a non-technical friend or family member.
    – rurp
    Commented Dec 9, 2021 at 22:51
  • 4
    In mac it's not obvious how
    – user4951
    Commented Dec 15, 2021 at 15:04
  • 1
    youtube.com/watch?v=sE_V0vzNTWQ
    – KcFnMi
    Commented May 25, 2022 at 3:45

31 Answers 31

61

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.

12
  • 32
    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
    Commented Jun 21, 2017 at 20:26
  • 4
    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. Commented Aug 25, 2017 at 20:28
  • 4
    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. Commented Jan 1, 2018 at 18:09
  • 7
    As of High Sierra, the easiest way to save as text is to select "Format" > "Make Plain Text" before saving a new file.
    – tripleee
    Commented Feb 2, 2018 at 8:16
  • 1
    Worsssst answer ever, in the entire stackexchage constelation
    – Marecky
    Commented Dec 12, 2022 at 14:15
110

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
13
  • 20
    any easy way to go the directory that I want? Unlike in windows I can't even copy that directory as text
    – user4951
    Commented Mar 5, 2013 at 14:57
  • 17
    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. Commented Mar 5, 2013 at 15:53
  • 4
    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
    Commented Mar 5, 2013 at 16:40
  • 89
    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! Commented Mar 17, 2015 at 5:16
  • 3
    @malhobayyeb My interpretation of this answer is "if you are okay with working on the command line anyway, it's not hard", rather than "you have to use the command line for this".
    – tripleee
    Commented Feb 2, 2018 at 8:25
91

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 (previously called a Service):

enter image description here

From the left side, 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:

Workflow 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.

16
  • 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. Commented Feb 2, 2018 at 22:33
  • 6
    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.
    – Andy Swift
    Commented Feb 5, 2018 at 14:03
  • 7
    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
    Commented Sep 29, 2018 at 18:02
  • 2
    @Kubuntuer82 This answer to “Right-click, create a new text file. How?” has additional code to check if the desktop is focused and to create the file differently if so. Commented Apr 28, 2019 at 20:31
  • 20
    Unbelievable (and unacceptable) that we have to waste time making a custom action in order to do a simple and basic thing that a GUI should have as a default. The solution works, perfectly, and this should be the accepted answer, even if it would be a standard feature of the OS. Commented May 1, 2020 at 14:10
26

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
  • 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. Commented Feb 1, 2018 at 1:26
18

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.

5
  • 2
    @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). Commented Jan 5, 2017 at 16:19
  • Hm, for me the script creates new untitled files in Applications folder and not in the current folder I'm in. Commented Jan 18, 2017 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? Commented Sep 27, 2017 at 13:49
  • Dragging it to the toolbar does nothing for me. Can you post a gif or something?
    – user27319
    Commented Nov 12, 2018 at 4:52
  • I couldn't type whatever I wanted, because TextEdit opened the recent file. When I found the command "New file" (in the dock's context menu!), it created an rtf file! Commented Jul 8, 2019 at 3:37
11

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!

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

New File Applescript with Toolbar Icon

Found this open source gem. Can either use the .App or add the Applescript manually. Will add a New File widget to the Finder toolbar.

New File Toolbar Icon

2
  • 4
    thanks, apple are so annoying to not have this natively.
    – ling
    Commented Nov 6, 2022 at 8:56
  • That's the most elegant solution I found of all. 😍 I built my own application from the .applescript that's locally signed and is trusted by my Mac. Commented Dec 2, 2023 at 5:35
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.

6
  • 1
    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
    Commented Oct 5, 2016 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
    Commented Jul 26, 2017 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. Commented Sep 27, 2017 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
    Commented Oct 11, 2017 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.
    – Andy Swift
    Commented Feb 2, 2018 at 20:32
6

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 ^^

Alternative code to handle files

The above code requires a folder to be selected to work, and does nothing if a file is selected. Changing the shell script code to the code snippet below will handle files as well, and create an empty file next to the selected file:

for df in "$@"; do

   if [[ -d "$df" ]]; then
      d="$df"

   elif [[ -e "$df" ]]; then
      d="$(dirname "$df")"

   fi

   touch "$d"/empty.txt
done
3
  • this looks great -- didn't know you could run shell scripts like this; I've never wanted to take the time to learn Applescript, it's so esoteric Commented Feb 25, 2021 at 15:23
  • adding a small edit suggestion to handle files a well -- in my test, the original code did nothing when the service was run while a file was selected, rather than a folder Commented Feb 25, 2021 at 15:44
  • But for this you need a shortcut. Is it also possible with a right click? So far I haven't found a solution ...
    – BabyBoy
    Commented Apr 24, 2021 at 5:36
5

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
  • 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
    Commented Oct 7, 2015 at 21:05
5

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

4
  • When I enter the name of a file and click OK, I get You don't have permission to create a file here Commented Jan 18, 2017 at 12:35
  • 1
    @JustAMartin Any method of creating a file will fail if you don't have the required permissions.
    – tripleee
    Commented Feb 2, 2018 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. Commented Feb 2, 2018 at 11:20
  • 1
    Thanks for this! By far the best solution I ran into after much googling. Such a basic function that MacOS doesn't support. Commented Aug 21, 2018 at 10:09
4

Reading through the previous answers, I decided to make a little AppleScript applet you can add to the toolbar in Finder. When clicked, it creates a new blank file in the current directory, letting you rename it immediately – just like in Windows.

In the future, I plan to implement it also as a Finder extension.

3

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

1
  • This is the best answer of all. $2 later and I can create different kinds of files easily, with the option to name them and/or open them straightaway if desired. Accessible by keyboard shortcut, context menu, or toolbar, whichever is preferred. This should just be how a Mac works by default! Commented Jun 15, 2022 at 20:52
3

NewFileClick has been very useful to create new files. It's very similar to the Windows "New File" feature, and it's free on the mac store:

https://www.newfileclick.com/

enter image description here

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.

1
  • Or use "stationary Pad" in the finder, which does this, and is a built in OS function.
    – stuffe
    Commented Dec 19, 2013 at 14:58
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

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

2

Amazing demonstration @Andrew Swift. I would add a few things to the script. First, add "at insertion location as alias" to cover the desktop. Second, ((current date) as string) as part of the file name to ensure that you can create multiple empty text files with different names (Timestamps are cool)

on tell application "Finder"
    set txt to make new file at insertion location as alias with properties {name:"New_text_" & ((current date) as string) & ".txt"}
    select txt
end tell
5
  • Hi Kano, welcome to Ask Different! It’s good that you’re contributing to our community. However, could you place this as a comment to Andrew Swift’s answer instead of making a new answer altogether?
    – brickery
    Commented Aug 31, 2019 at 23:30
  • Hey Brick, I have actually tried to reply to his comment but I was not able to do it, since my reputation point was too low to do so. If you know a way to make it happen please let me know. Meanwhile I just wanted to leave the message here anyways since people were looking for a way to do this.
    – Prometheus
    Commented Sep 2, 2019 at 17:27
  • I believe you can ask good questions or give good answers which will quickly increase your reputation points so that you can comment. You can see this link for more information: meta.stackexchange.com/questions/214173/…
    – brickery
    Commented Sep 3, 2019 at 6:04
  • 1
    That is what I intended to do. The code I posted is an answer to the specific question. It just happens that my solution was based on Andrew Swifts :) Regardless, I will be more mindful of where I post things, thank you.
    – Prometheus
    Commented Sep 4, 2019 at 16:17
  • Ah okay, must be my bad then.
    – brickery
    Commented Sep 6, 2019 at 0:23
2

Mac being mac, this is the simplest I could think of, out of the box:

  1. Right click on folder, select Services > New Terminal at Folder
  2. On terminal type touch yourfile.txt
  3. Cmd+Q on terminal
3
  • 1
    How is this different than the answers already provided? The second-highest voted answer is almost identical to your answer.
    – fsb
    Commented Apr 15, 2021 at 20:14
  • 1
    Almost. Starting a terminal, cd'ing to a directory, and touching a file is more verbose than right click'ing and simply touching a file.
    – jfaleiro
    Commented Apr 22, 2021 at 17:05
  • Instead of creating a new answer for substantially the same info, you should gain more reputation on the site so you can add comments and edit existing answers. That's the preferred method on the SE sites.
    – fsb
    Commented Apr 22, 2021 at 19:10
1

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

1
  • Please provide a summary of the method. Links become outdated.
    – n1000
    Commented Mar 3, 2020 at 15:18
1

Open Finder and navigate to Applications. Locate TextEdit.app and open it. Select Format--->Make Plain Text (this can also be done using Shift+Command+T). Select File--->Save... and you can save this as a real empty plain text file of 0 bytes.

(I am using macOS Catalina now and saw that there were no clear, simple answers to this question, so I decided to post this as an answer.)

1

I use this plugin in Alfred

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.

screenshot of the Alfred plugin

0

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.

1
  • 1
    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
    Commented Feb 2, 2018 at 8:29
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
  • 1
    Finder creates files: archives. Commented Jul 8, 2019 at 4:09
0

Create a text file using TextEdit

  1. Open the TextEdit app on your Mac (Applications > TextEdit, or use Spotlight, press Command-Space bar, to search, find and open TextEdit). TextEdit is a text editing and word processing tool that comes with your Mac.
  2. In the TextEdit app, choose File > Open. TextEdit has two format modes: (a) plain text (.txt file) and (b) rich text (.rtf file). The difference is that .txt mode will not allow formatting, while .rtf mode will let you format like adding images, colors, tables etc.
  3. Default format is rich text format. You can change this by going to TextEdit > Preferences and select Plain Text. enter image description here
  4. You can also change the mode while you editing your text by going to Format > Make Plain Text or Format > Make Rich Text. If you change a .rtf file (rich text) to .txt file (plain text), your document will lose all formatting options. enter image description here
  5. Create and edit your text file
  6. And then go to File > Save to save your text file. enter image description here
  7. Name your file and save it. enter image description here

Found this useful guide from macReports website. Hope this helps!

0

I spotlight tex, which will immediately suggest TextEdit.app, hit enter, edit my document and navigate to the directory and Save it.

0

There is a simple way to create a text file directly in a (current) folder, at least in Mac Ventura. After clicking on Finder, look under Finder>Services to find

Finder>Services.

Click

New Terminal at Folder

After the blank terminal opens in the folder, type:

> myfile.txt

(including >) to generate the new text file in the folder.

Then click out of the terminal.

This, I think, is doable, without any additional mental burden or having to create scripts yourself.

1
  • How is this answer different from existing answers, most notably, the second highest voted one?
    – Allan
    Commented Jan 9 at 16:39
-1

Another workaround is to visit for example https://www.editpad.org/ and download a .txt file

1
  • We're trying to find the best answers and those answers will provide info as to why they're the best. Explain why you think the link you provided will answer the question. Answers should be self-contained so others can find them by using the search feature. Links can change and become outdated so we prefer the answers to not just be a link. See How to Answer on how to provide a quality answer. - From Review
    – fsb
    Commented Apr 15, 2021 at 20:10

You must log in to answer this question.

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