Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

In windows I right click and then there is an option to create a text file.

How to do so in mac?

share|improve this question
add comment

5 Answers

up vote 9 down vote accepted

You can also do this in Terminal. Go to the directory where you want to create the file, then run the following:

touch file.txt
share|improve this answer
    
any easy way to go the directory that I want? Unlike in windows I can't even copy that directory as text –  Jim Thio Mar 5 '13 at 14:57
    
In Terminal, you can type cd, then a space, then drag a folder onto the Terminal window and press Return to go to that folder. –  Kirk McElhearn Mar 5 '13 at 15:53
    
In 10.8 and later you can also drag the folder on a Terminal window while holding command. Or if you copy the folder, ⌘V inserts its path in Terminal. –  Lauri Ranta Mar 5 '13 at 16:40
add comment

There's two ways to do this, the easiest is the first option;

  1. Open TextEdit and type whatever you need into it then save it to the location you want the file to live.

    You can open TextEdit quickly by invoking Spotlight and being typing Tex..., you should see the top hit is the app you want so you can just press enter to open it.

  2. This is more involved and will require you to create an AppleScript. The contents of the script needs to be:

    tell application "Finder" to make new file at (the target of the front window) as alias

Export the script as an Application somewhere safe and make sure you tick Run Only when saving it. Then drag the resulting file to the toolbar in Finder

This will then allow you to create a blank text file in what ever window you're viewing in Finder called untitled which you can then double click to edit in TextEdit

The Ultimate Beginner’s Guide To AppleScript, is good if you want to know more about AppleScript.

share|improve this answer
add comment

I use PathFinder as a replacement for Finder and it includes this in its right-click context menu. It is prboably too expensive a solution just for this but if you want to have a better Finder for other reasons as well.

share|improve this answer
add comment

There are two useful utilities that you can download and install that will enable you to create a new text file (or RTF file) in a currently-open folder that you are viewing using the Finder.

The utilities are called NewTextFileHere and NewRTFHere and can be downloaded from

http://mac.softpedia.com/developer/Jonas-Wisser-37498.html

Icons for either of these apps can then be included on all of your Finder windows.

share|improve this answer
    
Or use "stationary Pad" in the finder, which does this, and is a built in OS function. –  stuffe Dec 19 '13 at 14:58
add comment

Here's my script for creating new files from a store of templates.

I run it with FastScripts using a keyboard shortcut, but you can save it to an applet and put it in the menu bar, create an automator action, etc.

-ccs

----------------------------------------------------------------------------
--       Author: Christopher Stone 
--      Created: 2012-10-26 : 01:27
--     Modified: 2012-10-26 : 18:26
--  Application: Finder
--      Purpose: Create a new file from a file-type list in the front Finder window using
--             : template files stored in a folder.
-- Dependencies: Template files provided by the user.
--    Templates: Auto-creates a Text template - others are for the user to supply.
----------------------------------------------------------------------------

try

  try
    set templateFolderPath to ((path to application support from user domain as text) & "Script_Support:New_File_Here!:")
    set templateFolder to alias templateFolderPath
  on error
    set newFilesHereFolder to quoted form of (POSIX path of templateFolderPath)
    set textTemplate to newFilesHereFolder & "Text_Template.txt"
    do shell script "mkdir -p " & newFilesHereFolder & ";
     touch " & textTemplate & ";
     open -R " & textTemplate
    return
  end try

  tell application "Finder"
    if front window exists then
      set winTarget to target of front window as alias
      set fileTemplateList to name of files of templateFolder

      tell me to set fileType to choose from list fileTemplateList with title "New_File_Here! Templates" with prompt ¬
        "Pick One or More:" default items {get item 1 of fileTemplateList} with multiple selections allowed

      if fileType ≠ false then
        set AppleScript's text item delimiters to (return & templateFolderPath)
        set itemsToCopy to paragraphs of ((templateFolder as text) & fileType)

        repeat with i in itemsToCopy
          set i's contents to i as alias
        end repeat

        set copiedFiles to duplicate itemsToCopy to winTarget
        select copiedFiles
      end if

    else
      error "No windows open in Finder!"
    end if
  end tell

on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try

----------------------------------------------------------------------------
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.