How To Mac

How to Create a Text File in Desktop and Folder on Mac

Written by John

If you're on Windows, right-click and select New Text Document to create a Text file. Mac doesn't support this option even if you are using newer versions such as macOS Monterey or macOS Ventura - but don’t worry! We will show how easy it can be with keyboard shortcuts in order for users of all skill levels could complete their task quickly and efficiently. The process starts by creating an empty text document at desktop or folder.

When you need to create text files on your Desktop or folder, use AppleScript. This simple programming language can help run the advanced properties of macOS quickly. The Shortcuts app is a great way to automate tasks and run AppleScript on macOS and for those of you using macOS Big Sur or earlier versions will want to use Automator to run AppleScript.

How to Create a Text File in Desktop and Folder on Mac

1. Use Shortcuts App

The Shortcuts app is a great way to make repetitive operations easier, like running AppleScript. In this tutorial we will see how it can be used from macOS Monterey and Ventura with ease!

To run Shortcuts App on you Mac. You can open it by using Spotlight search or go straight for the Applications > Utilities folder and find out in there!

To start, click on the + icon to create a New Shortcuts with named: "Create Text File". Next enter "AppleScript" into search bar right here; Once found drag & drop these files to your Shortcuts.

Add AppleScript in Shortcuts App

Copy the following code to AppleScript:

display dialog "What is Your File Name" default answer ""
set theAnswer to (text returned of result)
try
tell application "Finder" to make new file at 1st Finder window with properties {name:theAnswer & ".txt"}
on error
tell application "Finder" to make new file at desktop with properties {name:theAnswer & ".txt"}
return
end try

Then go to Settings option from right menu. Choose "Pin in Menu Bar" and under Use as Quick Action section, you can choose which shortcut key will execute your script when selected in "Run with" option.

Add Shortkey run Shortcuts to create a Text file

Next, you can save your Shortcuts to be used later. When going any folder or Desktop and running a Shortkey, it will create Text Files with your file name.

Create Text File on macOS Desktop

2. Use Automator

Automator is an app that runs on older macOS Version and allows you to create custom scripts for various tasks. These "Automator" apps can be run with Shortkey. While it's not as easy-to use compared with Shortcuts, we'll still guide beginners to creating Text File with Automator.

You can open the automate in Spotlight Search or by clicking on it from your Applications folder, select File and click on New button, then select Quick Action.

Create Quick Action in Automator

Find AppleScript in the search bar and then drag it into that section on your right. After you do this, copy everything code below into Applescript.

display dialog "What is Your File Name" default answer ""
set theAnswer to (text returned of result)
try
tell application "Finder" to make new file at 1st Finder window with properties {name:theAnswer & ".txt"}
on error
tell application "Finder" to make new file at desktop with properties {name:theAnswer & ".txt"}
return
end try

Add AppleScript in Automator

You can save this Quick Action with any name, in the tutorial we'll call it "Create Text File". You will find it under Services in your Finder window.

Create Text File in Finder Services

To add a Shortkey for "Create Text File" services, go to System Preference or System Settings > Keyboard > General > Create Text File then add your key combination.

Add Shortkey for Services in System Settings

Whether you're a beginner or an expert, there are always new ways to save time and improve your productivity with the power of automation. In this tutorial we learned how two different apps work for creating Text files on macOS. You can use Shortcuts app if you have a newer macOS version, but for older systems you can use Automator app. You can change the file extension and location in Applescript, for example from *.txt extension to *.docx or even something more creative like “My File.pdf”.

The code in AppleScript will find "1st Finder window" on Mac and then ask Finder app to create a TXT file on 1st Windows, so when you search for '1st Finder window' in desktop it'll show an error and you can use Function (try, on error) to ask Finder create a txt file on the Desktop.

Leave a Comment