Tagged: finder

New file in Mac OS X Finder

- by admin

Sometimes we need to create a file from Finder directly. And this is strange that Finder allows easily to create a folder but not a file! Although Linux and Windows file browsers have this option. So, let's enhance Finder!

First start Automator (Launchpad / Other / 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 select Library / Utilities in the left tree menu. Next drag (or just double click) "Run AppleScript" into the main working area (mid-right). Here you will get "Run AppleScript" box. Paste the following AppleScript into this 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

Next double click on "Set Value of a Variable" (also in the LIbrary / Utilities section). Click the "Variable" drop-down and create a new variable. Let's call it currentFolder.

Select Library / Text in the left tree menu. Next drag (or just double click) "New Text File" into the main working area (mid-right). Here you will get "New Text File" box.

Drag the variable you just created (currentFolder) from the Variable panel at the bottom of the Automator window to the "Where" selector of the "New Text File" action. Change "Encoding" to "Unicode (UTF-8)". Click the New Text File's "Options" button (at the bottom of the box) and select "Show this action when the workflow runs". This will allow you to specify the names of new files.



Save the service with "File / Save ..." top menu and give it a name (For example "New File"). 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 "New File" from the "Services" submenu. A dialog should appear requesting a filename. Enter one then click "Continue"; your new file should appear.



This obviously creates a text or RTF empty file (file with .txt or .rtf extension). You can change the extension to whatever you need as the last step.

« All tags