AppleScript for Creating a Text File in the Current Finder Directory




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

About: Too much television as a kid.

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"
        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.

Be the First to Share


    • Battery Powered Contest

      Battery Powered Contest
    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest



    Question 8 months ago

    This was SUPER helpful Thanks. I'm using it along with a script to sequentionally rename documents in order to then import into Evernote as multiple notes! Question, is there a way to add multiple, numbered documents with sequential content inside the text file itself, so you could say have inside the text document: Day 01, Day 02, etc. Thanks again!