{"id":483,"date":"2007-03-29T17:32:12","date_gmt":"2007-03-30T00:32:12","guid":{"rendered":"http:\/\/10.0.1.201\/?p=483"},"modified":"2007-03-29T17:32:12","modified_gmt":"2007-03-30T00:32:12","slug":"newhere-a-template-activation-applescript-app","status":"publish","type":"post","link":"https:\/\/strawhousepig.net\/wordpress\/2007\/03\/29\/newhere-a-template-activation-applescript-app\/","title":{"rendered":"NewHere &#8211; A template activation AppleScript app"},"content":{"rendered":"<p>An AppleScript (app) to duplicate any file you&#8217;ve added to its list to the folder of the frontmost Finder window.<br \/>\n<!--more--><br \/>\nAfter giving it a home, the way to use this app is to drag it into the Finder&#8217;s toolbar. Then you can simply click its icon to activate it whenever and where ever you are in the Finder.<\/p>\n<p>You can save any document of any type and select it using the &#8220;&#8211;Add new file&#8230;&#8221; 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 &#8220;NewHere&#8221; in your Application Support folder), enter a name for the <em>duplicate<\/em> that will be placed in the folder of the Finder&#8217;s frontmost window. Then, it will open. You can now choose that file whenever you run this script by selecting it from the list.<\/p>\n<p>Also includes the ability to <a href=\"http:\/\/strawhousepig.net\/?p=475\" title=\"Clone Finder window\">clone the frontmost Finder window.<\/a><\/p>\n<p>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&#8217;t know. There are however issues of &#8220;Replacing&#8221;. <strong>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!<\/strong> 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&#8230;<\/p>\n<p><a href=\"http:\/\/strawhousepig.net\/home\/NewHere.zip\">Download<\/a> &#8211; 20kB zip file<\/p>\n<p>Source of &#8220;main.scpt&#8221;:<br \/>\n<code>property first_run_dialog : \"This is the first time you've run NewHere.<\/p>\n<p>Files added to the list are located in:<br \/>\n~\/Library\/Application Support\/NewHere\/<\/p>\n<p>Removing a file from this folder removes it from the list.\"<br \/>\nproperty choose_prompt : \"Choose a document to place here\"<br \/>\nproperty start_doc_list : {\"--Open templates folder\", \"--Add new file...\", \"--Clone Finder window\"} -- Do NOT alter the order of or remove these three items!<br \/>\nproperty save_prompt : \"Enter a name for the new file.\"<\/p>\n<p>tell application \"Finder\"<br \/>\n\tset app_sup to folder (path to application support from user domain)<br \/>\n\tif not (exists folder \"NewHere\" of app_sup) then<br \/>\n\t\tdisplay dialog first_run_dialog<br \/>\n\t\tmake new folder at app_sup with properties {name:\"NewHere\"}<br \/>\n\telse<br \/>\n\t\ttry<br \/>\n\t\t\tset doc_list to start_doc_list & (name of every file of folder \"NewHere\" of app_sup as list)<br \/>\n\t\tend try<br \/>\n\tend if<br \/>\n\tset my_file to choose from list doc_list with prompt choose_prompt<br \/>\n\tif result is not false then<br \/>\n\t\tset my_dest to (folder of the front window) as alias<br \/>\n\t\tset my_file to item 1 of my_file as string<br \/>\n\t\tif my_file is item 1 of doc_list then<br \/>\n\t\t\ttell application \"Finder\" to open folder \"NewHere\" of app_sup<br \/>\n\t\telse if my_file is item 2 of doc_list then<br \/>\n\t\t\tset new_file to choose file without invisibles<br \/>\n\t\t\tduplicate file new_file to folder \"NewHere\" of app_sup with replacing<br \/>\n\t\t\tset my_name to text returned of (display dialog save_prompt default answer (name of my_dest & \" \" & name of new_file as text))<br \/>\n\t\t\tmy do_it((name of new_file as text), my_name, my_dest)<br \/>\n\t\telse if my_file is item 3 of doc_list then<br \/>\n\t\t\ttell application \"Finder\"<br \/>\n\t\t\t\ttry<br \/>\n\t\t\t\t\tset this_folder to folder of window 1<br \/>\n\t\t\t\t\tmake new Finder window to this_folder<br \/>\n\t\t\t\tend try<br \/>\n\t\t\tend tell<br \/>\n\t\telse<br \/>\n\t\t\tset my_name to text returned of (display dialog save_prompt default answer (name of my_dest & \" \" & my_file))<br \/>\n\t\t\tmy do_it(my_file, my_name, my_dest)<br \/>\n\t\tend if<br \/>\n\telse<br \/>\n\t\tset doc_list to start_doc_list<br \/>\n\tend if<br \/>\nend tell<\/p>\n<p>on do_it(my_file, my_name, my_dest)<br \/>\n\tset my_dest to my_dest & my_name as text<br \/>\n\tset my_origin to (path to application support from user domain) & \"NewHere:\" & my_file as text<br \/>\n\tdo shell script \"cp \" & quoted form of (POSIX path of my_origin) & \" \" & quoted form of (POSIX path of my_dest)<br \/>\n\ttell application \"Finder\" to open my_dest as alias<br \/>\nend do_it<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>An AppleScript (app) to duplicate any file you&#8217;ve added to its list to the folder of the frontmost Finder window.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[10,28],"class_list":["post-483","post","type-post","status-publish","format-standard","hentry","category-code","tag-applescript-2","tag-os-x"],"_links":{"self":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/comments?post=483"}],"version-history":[{"count":0,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/483\/revisions"}],"wp:attachment":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/media?parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/categories?post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/tags?post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}