# How to create a text file in a folder

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

How to do so in mac?

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.

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

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
• 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
• 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
• 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
• 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
• @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 Feb 2 '18 at 8:25

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):

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):

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.

• 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
• 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
• 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
• @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. – Rory O'Kane Apr 28 '19 at 20:31
• 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. – Alessandro C May 1 '20 at 14:10

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.

• 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

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.

• @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
• 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! – Evgeni Nabokov Jul 8 '19 at 3:37

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.

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

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

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
• @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 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

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

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

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
• @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

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

Create a new service in Automator

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

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

Save it.

## Done!

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

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 • 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 – spinup Feb 25 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 – spinup Feb 25 at 15:44 • good one, thanks! – illustribe Feb 26 at 19:52 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. 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. 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 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. On the mac in finder, select a .txt file, hold option and drag it to make a copy, then edit it as usual. 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 • 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? – Brick Aug 31 '19 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. – Kano Sep 2 '19 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/… – Brick Sep 3 '19 at 6:04 • 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. – Kano Sep 4 '19 at 16:17 • Ah okay, must be my bad then. – Brick Sep 6 '19 at 0:23 This article from MacWorld indicates how to create a service that creates a new text file. • Please provide a summary of the method. Links become outdated. – n1000 Mar 3 '20 at 15:18 I just downloaded New File menu (2$) from the app store and it seems to work fine.

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.

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

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.

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
New contributor
jfaleiro is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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

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

• Finder creates files: archives. – Evgeni Nabokov Jul 8 '19 at 4:09

## 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.
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.
5. Create and edit your text file
6. And then go to File > Save to save your text file.
7. Name your file and save it.

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

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

New contributor
Melounek is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• 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 Apr 15 at 20:10

Have a PC with Windows on board. In Windows Explorer, right-click inside any folder, choose Create text file. It creates the file. Upload the file to any cloud service, or attach to a letter. On your Mac, download the file wherever you want. Profit!