In windows I right click and then there is an option to create a text file.
How to do so in mac?
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.
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
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 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):
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.
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.
Here is my workaround:
Do this once, create an empty text file in your desktop to serve as template.
Opt/Alt-drag this file to the folder to make a copy.
There's two ways to do this, the easiest is the first option;
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.
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.
untitled
files in Applications folder and not in the current folder I'm in.
Commented
Jan 18, 2017 at 12:28
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 -
Ps. this app is also free!
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.
.applescript
that's locally signed and is trusted by my Mac.
Commented
Dec 2, 2023 at 5:35
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.
untitled
, then untitled 2
and so on wuthout causing an error.
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.
And if you want to add a keyboard shortcut to it, go to System Preferences > Keyboard
Enjoy ^^
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
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 ----------------------------------------------------------------------------
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
You don't have permission to create a file here
Commented
Jan 18, 2017 at 12:35
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 just downloaded New File menu (2$) from the app store and it seems to work fine.
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:
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.
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.
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.
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
Mac being mac, this is the simplest I could think of, out of the box:
Services > New Terminal at Folder
touch yourfile.txt
Cmd+Q
on terminalThis article from MacWorld indicates how to create a service that creates a new text file.
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.)
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.
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.
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:
If the file was already saved, to move a file you can call 'File > Move' and proceed similar to above.
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.
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
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.
Another workaround is to visit for example https://www.editpad.org/ and download a .txt file