Introduction: AppleScript for Creating a Text File in the Current Finder Directory

You know the situation: in OSX you simply want to create a quick textfile in your current Finder folder (dare I mention the Desktop?). AppleScript comes to the rescue!

Step 1: Add the AppleScript Icon to the OSX Menu Bar

Inside the AppleScript editor (in your OSX Applications - Utilities) go to Preferences - General and check

[x] Show Script menu in menu bar

Step 2: Add This Script to Your User Scripts

-- H.Zimmerman, AppleScript.
-- Create text file in current Finder folder with a dialog.


tell application "Finder"
    try
        display dialog "name of doc please (without the .txt thing)" default answer ""
        set fileName to the text returned of result
        if length of fileName = 0 then
            return 0
        end if
        set fileExt to ".txt"
        set thisFolder to the target of the front window as alias
        set newFile to fileName & fileExt
         
        make new file at thisFolder with properties {name:newFile, file type:"TEXT", creator type:"ttxt"}
    on error errMsg
        display dialog (errMsg)
    end try
end tell

Step 3: Make a Text File

In the appropriate Finder folder, simply select the menu item you just added, type a name and your file is there. Double clicking it will open the familiar Text Edit.

Comments

About This Instructable

1,130views

9favorites

License:

Bio: Too much television as a kid.
More by hzimmerman:Computing complex circuits with a TI calculatorHow to make your own delicious and healthy breadControlling a relay board with an Arduino Uno
Add instructable to: