Create a New File in the Finder

The Finder provides some easy ways to create new folders. (Control-click and select New Folder, select File -> New Folder, or press Command-Shift-N). But it doesn't provide an easy way to create new files. (The file managers in Windows and some flavors of Linux have create-new-file options in their contextual menus.) reader zsaeid figured out a workaround using Automator and Applescript:

Start by launching Automator. In the chooser that appears next, select Service. At the top of the Automator main window, set the Service Receives Selected drop-down to Files or Folders. Then drag the following actions into the work area:

Run AppleScript (in the Utilities section of the Actions library). Paste the following AppleScript into its code box, then click the hammer icon (to compile the code):

on run {input, parameters} tell application "Finder" set currentPath to insertion location as text set x to POSIX path of currentPath end tell return x end run

Below that, insert Set Value of a Variable (also in the Utilities section). Click the Variable drop-down and create a new variable. (I called mine CurrentFolder.)

Follow that with the New Text File action (from the Text section of the Actions library). Drag the variable you just created (CurrentFolder) from the Variable panel at the bottom of the Automator window to the Where section of the New Text File action. Click the New Text File's Options button and select Show This Action When the Workflow Runs. (This will allow you to specify the names of new files.)

Save the service and give it a name (Create New File or whatever else you like). To test it, in the Finder go to the folder where you want to create a new file. Control-click on an existing file within that folder and select Create New File from the Services submenu. A dialog should appear requesting a filename. Supply one then click Continue; your new file should appear.

At least one Hints reader wondered why, exactly, you'd want to do this in the first place. Consider it a reversal of the usual Mac workflow: Instead of creating a new file within an application and, when you save it, navigating to the folder where you want to store it, you're creating the file where you want it first. You can then open the new file in whatever application you'd like. Also, note that this service is a homemade (and less versatile) version of the utilities Document Palette ( Macworld rated 4.5 out of 5 mice ) and NuFile ( Macworld rated 3.5 out of 5 mice ).

This story, "Create a New File in the Finder" was originally published by Macworld.

To comment on this article and other PCWorld content, visit our Facebook page or our Twitter feed.
Shop Tech Products at Amazon