Create shortcut for new .txt (or any) file in OSX

PART I. CREATE AN APPLE SCRIPT VIA AUTOMATOR

Step 1. Open application.

Step 2. Create new .

Step 3. Set to

Step 4. Drag the action in the workflow area.

Step 5. Delete the default content and paste the code below:

on run {input, parameters}try    tell  "Finder" to set the thisFolder to ( of the front ) as on error -- if no folder is open in finder or focused in running application, set default location to desktop    set the thisFolder to path to end tryset fileName to text returned of (display dialog "Create new .txt file named:" default answer "Textfile.txt")
set filePath to POSIX path of thisFolder
set theFile to filePath & fileName
set prefixString to "copy of "
-- if filename already existing, this service will ask for a new filename
tell "Finder"
repeat while exists theFile as set fileName to text returned of (display dialog "\"" & fileName & "\" already exists, please provide another name:" default answer prefixString & "Textfile.txt")
set theFile to filePath & fileName
set prefixString to prefixString & "copy of "
end repeat
end telldo shell script "touch \"" & theFile & "\""return input
end run

Step 6: Save as (or any other desired name).

STEP 7: Close

PART II. SET UP KEYBOARD SHORTCUT FOR THE NEW SERVICE

Step 1: Search in Spotlight.

Step 2: Open tab.

Step 3: Select from left panel.

Step 4: Look for item.

Step 5: Assign keyboard shortcut by selecting service and click button.

Step 6: Assign desired keyboard shortcut.

Step 7: Close System Preferences.

Step 8: Test by pressing your keyboard shortcut.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store