NewHere – A template activation AppleScript app

An AppleScript (app) to duplicate any file you’ve added to its list to the folder of the frontmost Finder window.

After giving it a home, the way to use this app is to drag it into the Finder’s toolbar. Then you can simply click its icon to activate it whenever and where ever you are in the Finder.

You can save any document of any type and select it using the “–Add new file…” option when prompted for a document to place. For example, you can set-up and save an Illustrator, Photoshop, HTML, plain text, etc. document to use as a template with this script. Add it to the list (which is really just adding a duplicate of the template to a folder named “NewHere” in your Application Support folder), enter a name for the duplicate that will be placed in the folder of the Finder’s frontmost window. Then, it will open. You can now choose that file whenever you run this script by selecting it from the list.

Also includes the ability to clone the frontmost Finder window.

This has not been tested extensively, so there may be some unexpected behavior if your list gets very big. Or there may not, I really don’t know. There are however issues of “Replacing”. This will not replace a file if you pick the same name as a file already in the folder you use it on without prompting! So please be aware of what you are doing because the older file will be opened as if it were new. I do plan to change this behavior, however. Someday…

Download – 20kB zip file

Source of “main.scpt”:

property first_run_dialog : "This is the first time you've run NewHere.

Files added to the list are located in:
~/Library/Application Support/NewHere/

Removing a file from this folder removes it from the list."
property choose_prompt : "Choose a document to place here"
property start_doc_list : {"--Open templates folder", "--Add new file...", "--Clone Finder window"} -- Do NOT alter the order of or remove these three items!
property save_prompt : "Enter a name for the new file."

tell application "Finder"
  set app_sup to folder (path to application support from user domain)
  if not (exists folder "NewHere" of app_sup) then
    display dialog first_run_dialog
    make new folder at app_sup with properties {name:"NewHere"}
      set doc_list to start_doc_list & (name of every file of folder "NewHere" of app_sup as list)
    end try
  end if
  set my_file to choose from list doc_list with prompt choose_prompt
  if result is not false then
    set my_dest to (folder of the front window) as alias
    set my_file to item 1 of my_file as string
    if my_file is item 1 of doc_list then
      tell application "Finder" to open folder "NewHere" of app_sup
    else if my_file is item 2 of doc_list then
      set new_file to choose file without invisibles
      duplicate file new_file to folder "NewHere" of app_sup with replacing
      set my_name to text returned of (display dialog save_prompt default answer (name of my_dest & " " & name of new_file as text))
      my do_it((name of new_file as text), my_name, my_dest)
    else if my_file is item 3 of doc_list then
      tell application "Finder"
          set this_folder to folder of window 1
          make new Finder window to this_folder
        end try
      end tell
      set my_name to text returned of (display dialog save_prompt default answer (name of my_dest & " " & my_file))
      my do_it(my_file, my_name, my_dest)
    end if
    set doc_list to start_doc_list
  end if
end tell

on do_it(my_file, my_name, my_dest)
  set my_dest to my_dest & my_name as text
  set my_origin to (path to application support from user domain) & "NewHere:" & my_file as text
  do shell script "cp " & quoted form of (POSIX path of my_origin) & " " & quoted form of (POSIX path of my_dest)
  tell application "Finder" to open my_dest as alias
end do_it

One thought on “NewHere – A template activation AppleScript app

  1. Pingback: Clone Finder window |

Leave a Reply

Your email address will not be published. Required fields are marked *