FasdUAS 1.101.10 k l  Populate Template Placeholders This script populates a copy of a template by replacing placeholders with text. by Curt Clifton Copyright 2007, Curtis Clifton All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Version History: 0.5.2 updated for OmniFocus AppleScript implementation change 0.5.1 updated for OmniFocus AppleScript dictionary change 0.5, added Growl notifications, better error checking, bug fix in date handling, work around for OF multiple-window bug, and replacement of placeholders in notes 0.4, automatically duplicates the project, works with content pane or sidebar selection 0.3, now works for subprojects 0.2, clears placeholders from note of project 0.1, initial release, 6/13/07   D Populate Template Placeholders This script populates a copy of a template by replacing placeholders with text. by Curt Clifton Copyright 2007, Curtis Clifton All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: " Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. " Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Version History: 0.5.2 updated for OmniFocus AppleScript implementation change 0.5.1 updated for OmniFocus AppleScript dictionary change 0.5, added Growl notifications, better error checking, bug fix in date handling, work around for OF multiple-window bug, and replacement of placeholders in notes 0.4, automatically duplicates the project, works with content pane or sidebar selection 0.3, now works for subprojects 0.2, clears placeholders from note of project 0.1, initial release, 6/13/07  l  WQ Activate, Relocate New Template Addon by Rebecca O'Connell (except where noted)   Activate, Relocate New Template Addon by Rebecca O'Connell (except where noted)   j &0placeholderopenerplaceholderOpener m j &0placeholdercloserplaceholderCloser m l l MG The following properties are used for script notification via Growl.  The following properties are used for script notification via Growl.  ! j" 0 growlappname growlAppName "m##$$Curt's Scripts!%& %j ' 20scriptstartnotificationscriptStartNotification 'm (())Script Began&*+ *j , 40scriptfinishnotificationscriptFinishNotification ,m --.. Script Completed+/0 /j1 ,0defaultnotificationsdefaultNotifications 1J223 3o 40scriptfinishnotificationscriptFinishNotification045 4j6 $0allnotificationsallNotifications 6b78 7o ,0defaultnotificationsdefaultNotifications 8J99: :o 20scriptstartnotificationscriptStartNotification5;< ;j= 00iconloaningapplicationiconLoaningApplication =m>>??OmniFocus.app<@A @lABC BlDE D93 Activate, Relocate New Template Script Properties EFFf Activate, Relocate New Template Script Properties CGH Gj I 60locationplaceholderopenerlocationPlaceholderOpener ImJJKK{HLM Lj!%N 60locationplaceholdercloserlocationPlaceholderCloser Nm!$OOPP}MQR QlRST Sl@U UO@VW Vk?XXYZ YO[\ [k ]]^_ ^O 0`a `l/bcd bk/eefg frhi hnjk j2  OTst k1  FCcn io $0theselecteditemstheSelectedItemsgl lZ/mn ml!o o>!pq plr rIs .corecnte******** so $0theselecteditemstheSelectedItems qm  nk$+ttuv ul$$wx w try sidebar selectionxyy, try sidebar selectionvz zr$+{| {n$)}~ }2')  OTst ~1$'  FCSt |o $0theselecteditemstheSelectedItems c/) (first document window whose index is 1)dR (first document window whose index is 1) a4   FCdw m _ l11 l11 Z1K l18 A18 l16 I16 .corecnte******** o12 $0theselecteditemstheSelectedItems m67 k;G I;D .sysodisAaleRTEXT m;<\You must first select the project to populate.  mesS m=>jSelect a project that includes template placeholders.  as A m?@  EAlTwarN LEG lLL C= More that one selected item is allowed, so comment this out if ((count of theSelectedItems) > 1) then display alert "You must select just one project." message "Select a single project that includes template placeholders, but dont select the actions and subprojects under it." as warning return end if z More that one selected item is allowed, so comment this out if ((count of theSelectedItems) > 1) then display alert "You must select just one project." message "Select a single project that includes template placeholders, but don t select the actions and subprojects under it." as warning return end if  lLL rLO mLM  boovtrue o 40theselecteditemsarevalidtheSelectedItemsAreValid rPV JPR o "0theplaceholdersthePlaceholders YW ke res neo 1ko  valL nek 4fk  cobj oij 0i oef $0theselecteditemstheSelectedItems o 0 selecteditem selectedItem ltt '!return properties of selectedItemBreturn properties of selectedItem rt~ nt| Iu| 0project_validity_check oux 0 selecteditem selectedItem ftu o 40theselecteditemsarevalidtheSelectedItemsAreValid l Z = o 40theselecteditemsarevalidtheSelectedItemsAreValid m  boovfals L k r n 4  cobj m o 40theselecteditemsarevalidtheSelectedItemsAreValid o *0theplaceholderstempthePlaceholdersTemp Y Z H E o "0theplaceholdersthePlaceholders l n 4  cobj o 0j o *0theplaceholderstempthePlaceholdersTemp r b o "0theplaceholdersthePlaceholders l n 4  cobj o 0j o *0theplaceholderstempthePlaceholdersTemp o "0theplaceholdersthePlaceholders 0j m l I~ .corecnte******** o} }*0theplaceholderstempthePlaceholdersTemp~ r n 4| | cobj m{{ oz z40theselecteditemsarevalidtheSelectedItemsAreValid oy y 0theprojectnametheProjectNamex lwvuwvux 0i mZ[tt l[`sr I[`qp q.corecnte******** o[\o o$0theselecteditemstheSelectedItemspsr lnmlnml r Jkk oj j*0thereplacementslisttheReplacementsList r n Iih i"0getreplacementsgetReplacements og g"0theplaceholdersthePlaceholdersf Jeefh f od d"0thereplacementstheReplacements l     Z  cb  la` = l_^ I]\ ].corecnte******** o[ ["0thereplacementstheReplacements\_^ mZZa` LYYcb   cancelled  cancelled  r  b  o  X X*0thereplacementslisttheReplacementsList o W W"0thereplacementstheReplacements oV V*0thereplacementslisttheReplacementsList lUTSUTS r JRR  oQ Q0 newtemplates newTemplates!" !r##$ #JPP $oO O0 thetasklist theTaskList"%& %Y$'N()M 'k2**+, +r2@-. -n2</0 /18 =oEHD D"0theplaceholdersthePlaceholders>?@ ?oHKC C 0theprojectnametheProjectName@AB AoKNA A*0thereplacementslisttheReplacementsListBF 9fAB 7o@ @0 duplicateitem duplicateItem5BC BrWcDE DnW_FG F4Z_?H ? cobj Hm]^>> GoWZ= =0 duplicateitem duplicateItem Eo< <0 newtemplate newTemplateCIJ IrdpKL KndlMN M4gl;O ; cobj Omjk:: Nodg9 90 duplicateitem duplicateItem Lo8 8"0thereplacementstheReplacementsJPQ PrqRS RbqTU Toqt7 70 thetasklist theTaskList UJt~VVW6 Wnt|XY X4w|5Z 5 cobj Zmz{44 Yotw3 30 duplicateitem duplicateItem6 So2 20 thetasklist theTaskListQ[\ [r]^ ]n_` _41a 1 cobj am00 `o/ /0 duplicateitem duplicateItem ^o. .$0datedifferentialdateDifferential\bc bl-,+-,+cde dl*)(*)(ef' frgh gbij io& &0 newtemplates newTemplates jJkkl% lo$ $0 newtemplate newTemplate% ho# #0 newtemplates newTemplates' N0i (m'("" )l(-m! mI(-n .corecnte******** no() $0theselecteditemstheSelectedItems! M&op olpqr qYstu snvw vIx 0update_template_propertiesxyz yn{| {4}  cobj }o 0i |o 0 newtemplates newTemplatesz~ ~o "0theplaceholdersthePlaceholders o *0thereplacementslisttheReplacementsList n 4  cobj o 0i o 0 thetasklist theTaskList o $0datedifferentialdateDifferential  wf 0i tm   ul I .corecnte******** o 0 newtemplates newTemplates  r l l _YBegin Relocate New Template - attempts, and fails or succeeds, at each move individually Begin Relocate New Template - attempts, and fails or succeeds, at each move individually  Y n I 0move_new_template n 4  cobj o 0i o 0 newtemplates newTemplates f 0i m l I .corecnte******** o 0 newtemplates newTemplates \4  docu mZ l l l l A;Begin Activate, Relocate New Template updated notification vBegin Activate, Relocate New Template updated notification  l my notify("Template Populated", "The project template has been populated. Youll find it at the end of the project listing.", scriptFinishNotification)0my notify("Template Populated", "The project template has been populated. You ll find it at the end of the project listing.", scriptFinishNotification) Z= ? l I .corecnte******** o 0 newtemplates newTemplates m n  I  0notify m $Template Populated mThe project templates have been populated. If you specified location paths, your projects were moved to the approprate locations. Otherwise, you ll find them at the end of the project listing. o 40scriptfinishnotificationscriptFinishNotification f   =& l$ I$ .corecnte******** o 0 newtemplates newTemplates m$% n)9 I*9 0notify m*-$Template Populated m-0xThe project template has been populated. If you specified a location path, your project was moved to the appropriate location. Otherwise, you ll find it at the end of the project listing. o05 40scriptfinishnotificationscriptFinishNotification f)* l>> WmOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/T l l l TN Begin Subroutines culled from Populate Template Placeholders script sections  Begin Subroutines culled from Populate Template Placeholders script sections  i&) I 0move_new_template o 0 newtemplate newTemplate O O k  r  n  1   FCno o 0 newtemplate newTemplate o 0notestrnoteStr l +%return count of paragraphs of noteStrJreturn count of paragraphs of noteStr Q1 k% l r n 4  cpar m o 0notestrnoteStr o 0notestrnoteStr r#   n!   I! %0!parse_location_placeholder_string  o 0notestrnoteStr  f  o 0treepathtreePath l$$ R .ascrerr ******** r-1 J-/ o 0treepathtreePath Z2 l29 >29 l27 I27 .corecnte******** o23 0treepathtreePath m78 k< Q<k k?b  !" !r?P#$ #l?N% %c?N&' &n?L() (7BL*+  cpar *mFH +mIK )l?B, ,n?B-. -1@B  FCno .o?@ 0 newtemplate newTemplate 'mLM  ctxt $o 0 noteleftovers noteLeftovers"/0 /lQQ12 1-'take off excess leftover paragraph mark233Ntake off excess leftover paragraph mark04 4rQb56 5cQ^78 7lQ\9 9nQ\:; :7R\<=  cha <mVX =mY[ ;oQR 0 noteleftovers noteLeftovers 8m\]  ctxt 6n>? >1_a  FCno ?o^_ 0 newtemplate newTemplate R@ .ascrerr ******** @o 0errmsgerrMsg ljjAB A'!set note of newTemplate to errMsgBCCBset note of newTemplate to errMsgDE DrlrFG FnlpHI H4mpJ  cobj Jmno Iolm 0treepathtreePath Go 0treepathtreePathEKL Krs{MN MnsyOP OIty~Q} ~0get_specified_treeQR| Rotu{ {0treepathtreePath|} Pfst Noz z0 foundpath foundPathLST Sl||yxwyxwTUv UZ|VWuX V>|YZ Yo|}t t0 foundpath foundPath Zm}~s s boovfals Wr[\ [n]^ ]Ir_q r0move_to_section_`a `op p0treepathtreePathabo bon n0 newtemplate newTemplateoq ^f \om m0 movedtemplate movedTemplateu XIlck l.sysodlogaskrTEXT cmddeeThe location path you provided is not valid. The template was left at the bottom of the end of the project listing.kv 4jf j docu fmii mggOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/hi hlhgfhgfijk ji*-lm lIend e0update_template_propertiesnop ooc c 0duplicateditemduplicatedItempqr qob b"0theplaceholdersthePlaceholdersrst soa a"0thereplacementstheReplacementstuv uo` `0thetasktheTaskvw_ wo^ ^$0datedifferentialdateDifferential_d mOIxy xOHz{ zk G||}~ }r  n  1 ] ] FCno o \ \ 0duplicateditemduplicatedItem o[ [0thenotetheNote~ lZYXZYX r n IWV W00buildreplacementscriptbuildReplacementScript oU U"0theplaceholdersthePlaceholders oT T"0thereplacementstheReplacementsS mSV f oR R0 thecommand theCommand n$ I$QP Q*0replaceplaceholdersreplacePlaceholders oO O0thetasktheTask oN N0 thecommand theCommandM o L L$0datedifferentialdateDifferentialMP f l%%KJIKJI r%. l%,HG I%,F F&0stripplaceholdersstripPlaceholders f%&ED E from o'(C C0thenotetheNoteDHG oB B0thenotetheNote r/8 l/6A@ n/6 I06?> ?0 replacetext replaceText o01= =0thenotetheNote< o12; ;0 thecommand theCommand<> f/0A@ o: :0thenotetheNote l99987987 r9> o9:6 60thenotetheNote n 1;=5 5 FCno o:;4 4 0duplicateditemduplicatedItem l??33 IC Activate, Relocate New Template Script - make new projects active  Activate, Relocate New Template Script - make new projects active  r?D m?@2 2 FCPsFCPa n 1AC1 1 FCPs o@A0 0 0duplicateditemduplicatedItem/ LEG oEF. . 0duplicateditemduplicatedItem/ {4- - docu m,, ymOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/k l+*)+*) i.1 I(' (0duplicate_item o& &0 selecteditem selectedItem o% %"0theplaceholdersthePlaceholders o$ $ 0theprojectnametheProjectName# o" ""0thereplacementstheReplacements#' O O k  r  n  1 ! ! FCDs o 0 selecteditem selectedItem o 0 thestartdate theStartDate r n 1  FCDd o 0 selecteditem selectedItem o 0 theduedate theDueDate l I# .coreclon******** l o 0 selecteditem selectedItem  insh n 9  insl 4  FCSX m r$* 4$(  FCSX m&' o 0duplicateditemduplicatedItem l++  uo -- Experimental code to select the duplicate tell sidebar of document window 1 to select duplicatedItem  -- Experimental code to select the duplicate tell sidebar of document window 1 to select duplicatedItem  l++     Z+l l+. >+. o+, 0 theduedate theDueDate m,-  msng k1G   r1:   n18   I28 *0getdatedifferentialgetDateDifferential m23due o34 0 theduedate theDueDate f12  o $0datedifferentialdateDifferential  Z;G l;> =;> o;< $0datedifferentialdateDifferential m<=  msng LAC lJM >JM oJK 0 thestartdate theStartDate mKL  msng  kPf!!"# "rPY$% $nPW&' &IQW( *0getdatedifferentialgetDateDifferential()* )mQR++,, start*- -oRS 0 thestartdate theStartDate 'fPQ %o $0datedifferentialdateDifferential#. .ZZf/0 /lZ]1 1=Z]23 2oZ[ $0datedifferentialdateDifferential 3m[\  msng 0L`b ril45 4mij  msng 5o $0datedifferentialdateDifferential67 6nm}89 8In}: 0notify:;< ;mno==>>&Populating Template<?@ ?botAB AborCD CmopEEFFZDuplicating and populating the template for  Dopq 0theprojectnametheProjectName BmrsGGHH @I Ioty 20scriptstartnotificationscriptStartNotification 9fmn7JK Jl~~KLM LQ~NOP NrQR QJSST TlU UeV VnWX W1  FCrt Xo 0duplicateditemduplicatedItem Ro 0thetasktheTask ORYZ .ascrerr ******** Yo 0msgZ[  errn [o 0num PZ\]^ \=_` _o 0num `m\ ]rab aJccd do 0duplicateditemduplicatedItem bo 0thetasktheTask ^keefg fI .sysobeepnulllonggh hRij .ascrerr ******** io 0msgjk  errn ko 0numMl lLm mJnnop oo 0duplicateditemduplicatedItempqr qo "0thereplacementstheReplacementsrst so 0thetasktheTasktu uo $0datedifferentialdateDifferential 4v  docu vm mwwOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/xy xlyz{ zl{|} |i25~ ~I 0project_validity_check o 0 selecteditem selectedItem O O O  l k r n 1  pnam o 0 selecteditem selectedItem o 0theprojectnametheProjectName r n 1  FCno o 0 selecteditem selectedItem o 0thenotetheNote r" J  o "0theplaceholdersthePlaceholders Q#> k&5 r&, n&* 4'*  cpar m() o&' 0thenotetheNote o ,0theplaceholderstringthePlaceholderString r-5 n-3 I.3 00parseplaceholderstringparsePlaceholderString o./ ,0theplaceholderstringthePlaceholderString f-. o "0theplaceholdersthePlaceholders R .ascrerr ******** Z? l?F =?F l?D I?D .corecnte******** o?@ "0theplaceholdersthePlaceholders mDE kI II .sysodisAaleRTEXT bIN bIL mIJThis project,  oJK 0theprojectnametheProjectName mLM , does not appear to contain a list of placeholders at the end of its note field.  mesS bOt bOn bOj bOd bO` bOZ bOX bOR mOPThe note of a project should end with a list of project placeholders, like: oPQ  ret oRW &0placeholderopenerplaceholderOpener mXYRoomName oZ_ &0placeholdercloserplaceholderCloser m`c odi &0placeholderopenerplaceholderOpener mjmClientName ons &0placeholdercloserplaceholderCloser  as A mwz  EAlTwarN  btns J} m}OK  dflt m L m  boovfals~ L J o} }"0theplaceholdersthePlaceholders| o{ { 0theprojectnametheProjectName|~ /) (first document window whose index is 1)R (first document window whose index is 1) 4 z z FCdw m yy 4x x docu mww mOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/} lvutvut lss 4. Activate, Relocate New Template Subroutines \ Activate, Relocate New Template Subroutines  lrqprqp i69 Ion o%0!parse_location_placeholder_stringm ol l0 thestring theStringmn k5 r n 1k k txdl  1j j ascr oi i0olddelimoldDelim   r   o h h60locationplaceholderopenerlocationPlaceholderOpener  n 1 g g txdl 1 f f ascr  r n 1e e rest n 2d d citm oc c0 thestring theString ob b0 firstparse firstParse r! oa a60locationplaceholdercloserlocationPlaceholderCloser n 1 ` ` txdl 1_ _ ascr r", !  I"*^"] ^&0cleanplaceholderscleanPlaceholders"#$ #o#$\ \0 firstparse firstParse$%[ %J$&ZZ[] !oY Y0 theresult theResult&' &r-2() (o-.X X0olddelimoldDelim )n*+ *1/1W W txdl +1./V V ascr',U ,L35- -o34T T0 theresult theResultU./ .lSRQSRQ/01 0lPONPON123 2lMLKMLK345 4i:=67 6IJ8I J0get_specified_tree89H 9oG G0treepathtreePathHI 7Og:; :kf<<=> =Oc?@ ?O bAB AkaCCDE Dr#FG F6!HI HnJK J4FL F OTtr LmEE K1D D FCSt I= MN M1C C pnam NmOOPPLibrary GoB B0 currenttree currentTreeEQR Ql$$A@?A@?RST Sr$,UV Un$*WX WI%*>Y= >0get_path_partsYZ< Zo%&; ;0treepathtreePath<= Xf$% Vo: :0 treepathparts treePathPartsT[\ [l--987987\]6 ]Y-a^5_`4 ^Q;\abc ar>Pde dl>Nf32 f6>Ngh gn>Bij i4?B1k 1 OTtr km@A00 jo>?/ /0 currenttree currentTree h=CMlm l1DF. . pnam mlGLn-, nnGLop o4IL+q + cobj qoJK* *0i poGI) )0 treepathparts treePathParts-,32 eo( (0 currenttree currentTree bR'r& '.ascrerr ******** ro% %0errmsgerrMsg& ckX\sstu tLXZv vmXY$ $ boovfalsuw# wl[["xy" x2, The one of the folders named does not existyzzX The one of the folders named does not exist# 50i _m01!! `I16 { .corecnte******** {o12 0 treepathparts treePathParts46 B4 |  FCdw |m  @4}  docu }m>~ ~Ldf ode 0 currenttree currentTree ;mOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/5 l i>A I 0move_to_section o 0treepathtreePath o 0 newtemplate newTemplate O k O k  r  n  I  0get_path_parts o 0treepathtreePath  f o 0 treepathparts treePathParts l    QL kB I/ .coremovenullobj o 0 newtemplate newTemplate  insh n+ 9)+  insl l) 6) 4  FCSX m =( 1!  pnam l"' n"' 4$'  cobj m%& o"$ 0 treepathparts treePathParts r0B l0@ 60@ 404  FCSX m23 =5? 168  pnam l9> n9> 4;>  cobj m<= o9; 0 treepathparts treePathParts o 0currentsectioncurrentSection R .ascrerr ******** LJL mJK  boovfals YM Q[ k^ I^v .coremovenullobj o^_ 0 newtemplate newTemplate  insh n`r 9pr  insl l`p 6`p n`d 4ad  FCSX mbc o`a 0currentsectioncurrentSection =eo 1fh  pnam lin nin 4kn  cobj olm 0i oik 0 treepathparts treePathParts rw lw 6w nw{ 4x{  FCSX myz owx 0currentsectioncurrentSection =| 1}  pnam l n 4  cobj o 0i o 0 treepathparts treePathParts o 0currentsectioncurrentSection R .ascrerr ******** o 0errmsgerrMsg k L m  boovfals l 2, The one of the folders named does not existX The one of the folders named does not exist 0i mPQ IQV .corecnte******** oQR 0 treepathparts treePathParts I .coremovenullobj o 0 newtemplate newTemplate  insh n 9  insl l n 4  FCSX m o 0currentsectioncurrentSection 4  docu m L o 0currentsectioncurrentSection mOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/ l iBE   I 0get_path_parts   o 0treepathtreePath  k/   r  n I 0explode m: o 0treepathtreePath m  boovfals f o 0 pathparts pathParts Y , r'!" !n"#$ #I"% 0trim%& &n'( '4)  cobj )o 0i (o 0 pathparts pathParts $f "n*+ *4#&,  cobj ,o$% 0i +o"# 0 pathparts pathParts 0i m  l- -I. .corecnte******** .o 0 pathparts pathParts/ /L-/0 0o-. 0 pathparts pathParts12 1l234 3iFI56 5I7 0explode789 8o 0 delimiter9:; :o 0sometextsomeText;< <o 0limit 6k==>? >l@A @JD by Bruce Phillips http://bbs.applescript.net/viewtopic.php?id=18377ABB by Bruce Phillips http://bbs.applescript.net/viewtopic.php?id=18377?CD CrEF EcGH Go 0limit Hm  long Fo 0limitDIJ Ir KL Kn MN M1  txdl N1  ascr Lo 0prevtidsprevTIDsJOP Or QR Qo 0 delimiter RnST S1  txdl T1 ~ ~ ascrPUV UrWX WnYZ Y2} } citm Zo| |0sometextsomeText Xo{ { 0outputV[\ [lzyxzyx\]^ ]Zv_`aw _Bbc bov v 0limit cmuu `QFdef dZ!:ghts gA!$ij io!"r r 0limit jm"#qq hr'6kl kn'4mn m7(4pop p cobj om,.oo pl/3qnm q\/3rs ro01l l 0limit sm12kknm no'(j j 0output loi i 0outputts eRhgf h.ascrerr ********gf frBFtu tJBDee uod d 0outputavw vAIRxy xoIJc c 0limit ylJQzba z\JQ{| {lJO}`_ }IJO^~] ^.corecnte******** ~oJK\ \ 0output]`_ |mOP[[bawZ rUr bUp lU`YX nU` 7V`W W cobj mZ\VV o]_U U 0limit oUVT T 0outputYX l `oSR l`oQP b`o m`a nan 7bnO O cobj lfjNM [fj oghL L 0limit mhiKKNM mkmJJ oabI I 0outputQPSR oH H 0outputZw^ lwwGFEGFE rw| owxD D0prevtidsprevTIDs n 1y{C C txdl 1xyB B ascr l}}A@?A@?> L} o}~= = 0output>4 l<;:<;: iJM I98 90trim7 o6 60s78 kS l55 _Yby John Delacour http://lists.apple.com/archives/applescript-users/2002/Aug/msg00161.htmlby John Delacour http://lists.apple.com/archives/applescript-users/2002/Aug/msg00161.html l432432 r J1 10 0 spac1 n 1/ / txdl 1. . ascr r  n  2 - - citm o , ,0s o+ +0l r J* m* n 1) ) txdl 1( ( ascr l'&%'&% l$$ D> Prepend a space to every non-blank text item except the first| Prepend a space to every non-blank text item except the first r m# # boovfals o" " 0started XN! Z*I  ?*1 l*/ I*/ .corecnte******** o*+ 0thisitemthisItem m/0 Z4E o45  0started r8? l8; b8; 189  spac o9: 0thisitemthisItem n 1<>  pcnt o;< 0thisitemthisItem rBE mBC  boovtrue o  0started  !0thisitemthisItem o 0l lOO     LOS cOR oOP 0l mPQ  TEXT  l l l 82 Begin Populate Template Placeholders Subroutines d Begin Populate Template Placeholders Subroutines  l iNQ I 00parseplaceholderstringparsePlaceholderString o 0 thestring theString k5 r n 1  txdl 1  ascr o 0olddelimoldDelim   l    r   o &0placeholderopenerplaceholderOpener n 1   txdl 1  ascr  r n 1  rest n 2  citm o 0 thestring theString o 0 firstparse firstParse r! o &0placeholdercloserplaceholderCloser n 1  txdl 1  ascr r",!" !I"*# &0cleanplaceholderscleanPlaceholders#$% $o#$ 0 firstparse firstParse%& &J$& "o 0 theresult theResult '( 'l--()* )r-2+, +o-. 0olddelimoldDelim ,n-. -1/1  txdl .1./  ascr*/ /L350 0o34 0 theresult theResult12 1l234 3l56 5SM assumes that AppleScript's text item delimiters is set to placeholderCloser 677 assumes that AppleScript's text item delimiters is set to placeholderCloser 489 8iRU:; :I< &0cleanplaceholderscleanPlaceholders<=> =o 0thelisttheList>? ?o 0accum ;k;@@AB AZ CD ClE E=FG Fo 0thelisttheList GJ DL H Ho 0accumBIJ IrKL KnMN M4O  cobj Om No 0thelisttheList Lo 0 firstitem firstItemJPQ PrRS RnTU T4V  citm Vm Uo 0 firstitem firstItem So 0 firstitem firstItemQWX WZ0YZ Yl%[ [>%\] \l#^ ^I#_ .corecnte******** _n`a `2  cha ao 0 firstitem firstItem ]m#$ Zr(,bc bo() 0 firstitem firstItem cnde d;*+ eo)* 0accumXf fL1;g gI1:h &0cleanplaceholderscleanPlaceholdershij in25kl k135  rest lo23 0thelisttheListjm mo56 0accum9no nlopq piVYrs rIt "0getreplacementsgetReplacementstuv uo "0theplaceholdersthePlaceholdersvw wo 0accum skGxxyz yZ {| {l} }=~ ~o "0theplaceholdersthePlaceholders J |L  o 0accumz r n 4  cobj m o "0theplaceholdersthePlaceholders o 0theplaceholderthePlaceholder Q5 O* r) I' .sysodlogaskrTEXT b o 0theplaceholderthePlaceholder m:  dtxt m !  appr m"#BEnter replacement for placeholder o 0reply mOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/ R .ascrerr ******** L25 J24 r6< l69 n69 179  ttxt o67 0reply n ;:; o9: 0accum L=G I=F "0getreplacementsgetReplacements n>A 1?A  rest o>? "0theplaceholdersthePlaceholders oAB 0accumq l iZ] I *0getdatedifferentialgetDateDifferential o 0datekinddateKind o 0 originaldate originalDate ke r m~ ~ boovfals o} }0 validinput validInput r m o| |0 theanswer theAnswer W` k[ O" r! I{ {.sysodlogaskrTEXT lzy b b m Enter ox x0datekinddateKind m" date for projectzyw w dtxt ov v0 theanswer theAnswerut u appr mEnter Datet os s0thereplytheReply mOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/ Q#5 r&+ n&) 1')r r ttxt o&'q q0thereplytheReply op p0 theanswer theAnswer Ronm o.ascrerr ********nm k35 l33ll  user cancelled user cancelledk L35 m34j j msngk Q6L k9C r9? 49=i i ldt o; >"0theplaceholdersthePlaceholders &o= =0oldtextoldText$*+ *r,- ,n./ .4<0 < cobj 0m;; /o: :"0thereplacementstheReplacements -o9 90newtextnewText+12 1r334 3b156 5b/78 7b-9: 9b+;< ;b%=> =b#?@ ?mAABB | sed 's| @o"8 8&0placeholderopenerplaceholderOpener >o#$7 70oldtextoldText <o%*6 6&0placeholdercloserplaceholderCloser :m+,CCDD| 8o-.5 50newtextnewText 6m/0EEFF|g' 4o4 40 commandpart commandPart2GH Gr49IJ Ib47KL Ko453 3 0accum Lo562 20 commandpart commandPart Jo1 1 0accumHM0 ML:GN NI:F/O. /00buildreplacementscriptbuildReplacementScriptOPQ Pn;>RS R1<>- - rest So;<, ,"0theplaceholdersthePlaceholdersQTU Tn>AVW V1?A+ + rest Wo>?* *"0thereplacementstheReplacementsUX) XoAB( ( 0accum).0YZ Yl'&%'&%Z[\ [ibe]^ ]I$_# $*0replaceplaceholdersreplacePlaceholders_`a `o" "0thetaskstheTasksabc bo! !0 thecommand theCommandcd do $0datedifferentialdateDifferential # ^k$eefg fZ hi hlj j=kl ko 0thetaskstheTasks lJ iL gmn mIo >0replaceplaceholdersinchildrenreplacePlaceholdersInChildrenopq pnrs r4t  cobj tm so 0thetaskstheTasksquv uo 0 thecommand theCommandvw wo $0datedifferentialdateDifferentialnx xI$y *0replaceplaceholdersreplacePlaceholdersyz{ zn|} |1  rest }o 0thetaskstheTasks{~ ~o 0 thecommand theCommand o  $0datedifferentialdateDifferential  \ l ifi I >0replaceplaceholdersinchildrenreplacePlaceholdersInChildren o 0thetasktheTask o 0 thecommand theCommand o $0datedifferentialdateDifferential wT kT r l  n  I  0 replacetext replaceText c n 1  pnam o 0thetasktheTask m  TEXT o 0 thecommand theCommand f n 1  pnam o  0thetasktheTask r l n I 0 updatedate updateDate n 1  FCDd o 0thetasktheTask o $0datedifferentialdateDifferential f n 1  FCDd o 0thetasktheTask r - l ) n ) I!) 0 updatedate updateDate n!$ 1"$  FCDs o!" 0thetasktheTask o$% $0datedifferentialdateDifferential f ! n 1*,  FCDs o)* 0thetasktheTask Z.I l.3 >.3 n.1 1/1  FCno o./ 0thetasktheTask m12  msng r6E l6A n6A I7A 0 replacetext replaceText c7< n7: 18:  FCno o78 0thetasktheTask m:;  TEXT o<= 0 thecommand theCommand f67 n 1BD  FCno oAB 0thetasktheTask nJT IKT *0replaceplaceholdersreplacePlaceholders nKN 2LN  FCac oKL 0thetasktheTask oNO 0 thecommand theCommand oOP $0datedifferentialdateDifferential fJKOFOCalis:HD~(H+ 2 OmniFocus.appaè Applications~nèh 2HD:Applications:OmniFocus.app OmniFocus.appHDApplications/OmniFocus.app/ l ijm I 0 replacetext replaceText o 0thetexttheText o 0 thecommand theCommand k r n 1  strq o 0thetexttheText o 0 quotedtext quotedText r I .sysoexecTEXTTEXT b  b  m echo o 0 quotedtext quotedText o 0 thecommand theCommand o 0 quotedtext quotedText L o 0 quotedtext quotedText l inq I 0 updatedate updateDate o 0 originaldate originalDate  o $0datedifferentialdateDifferential k     Z   l  G  = o 0 originaldate originalDate m  msng =  o $0datedifferentialdateDifferential m  msng L m  msng  r [ o 0 originaldate originalDate o $0datedifferentialdateDifferential o 0newdatenewDate L o 0newdatenewDate l !" !iru#$ #I% &0stripplaceholdersstripPlaceholders%&  from &o 0thenotetheNote $k%''() (Z*+ *l , ,= -. -l/ /I0 .corecnte******** 0n12 12  cpar 2o 0thenotetheNote .m +L 3 3m 4455)67 6r"89 8n :; :7 <=  ctxt <4>  cpar >m =4?  cpar ?m ;o 0thenotetheNote 9o 0 noteparts noteParts7@ @L#%A Ao#$ 0 noteparts noteParts"BC BlCDE Dl~}|~}|EFG Fl{HI{ H  Uses Growl to display a notification message. theTitle a string giving the notification title theDescription a string describing the notification event theNotificationKind a string giving the notification kind (must be an element of allNotifications) IJJ Uses Growl to display a notification message. theTitle  a string giving the notification title theDescription  a string describing the notification event theNotificationKind  a string giving the notification kind (must be an element of allNotifications) GKL KivyMN MIzOy z 0notifyOPQ Pox x0thetitletheTitleQRS Row w 0thedescriptiontheDescriptionSTv Tou u*0thenotificationkindtheNotificationKindvy NO4UV Uk3WWXY XI!tsZ t.registernullnullsZr[\ r appl [o q q0 growlappname growlAppName\p]^ p anot ]o o o$0allnotificationsallNotifications^n_` n dnot _om m,0defaultnotificationsdefaultNotifications`lak l iapp aoj j00iconloaningapplicationiconLoaningApplicationkYbi bI"3hgc h.notifygrnullnullgcfde f name do$%e e*0thenotificationkindtheNotificationKindedfg d titl fo&'c c0thetitletheTitlegbhi b appl ho(-a a0 growlappname growlAppNamei`j_ ` desc jo./^ ^ 0thedescriptiontheDescription_i Vmkk@GRRRalisHD~(H+cGrowlHelperApp.appU Resources~nUNcbas|cg^HD:Users:rloconne:Library:PreferencePanes:Growl.prefPane:Contents:Resources:GrowlHelperApp.app&GrowlHelperApp.appHD[Users/rloconne/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app/Llm ll]\[]\[mno nlZYXZYXopq plWVUWVUqrs rlTSRTSRstu tlQPOQPOuvN vlMLKMLKN"Jw#(-xy>JOz{|}~Jw IHGFEDCBA@?>=<;:9876543210/.-,+* I&0placeholderopenerplaceholderOpener H&0placeholdercloserplaceholderCloser G0 growlappname growlAppName F20scriptstartnotificationscriptStartNotification E40scriptfinishnotificationscriptFinishNotification D,0defaultnotificationsdefaultNotifications C$0allnotificationsallNotifications B00iconloaningapplicationiconLoaningApplication A60locationplaceholderopenerlocationPlaceholderOpener @60locationplaceholdercloserlocationPlaceholderCloser ?0move_new_template >0update_template_properties =0duplicate_item <0project_validity_check ;%0!parse_location_placeholder_string :0get_specified_tree 90move_to_section 80get_path_parts 7 0explode 60trim 500parseplaceholderstringparsePlaceholderString 4&0cleanplaceholderscleanPlaceholders 3"0getreplacementsgetReplacements 2*0getdatedifferentialgetDateDifferential 100buildreplacementscriptbuildReplacementScript 0*0replaceplaceholdersreplacePlaceholders />0replaceplaceholdersinchildrenreplacePlaceholdersInChildren .0 replacetext replaceText -0 updatedate updateDate ,&0stripplaceholdersstripPlaceholders + 0notify *.aevtoappnull****x))-y((-(z'&%$ '0move_new_template&##" "0 newtemplate newTemplate%!  !0 newtemplate newTemplate 0notestrnoteStr 0treepathtreePath 0 noteleftovers noteLeftovers 0errmsgerrMsg 0 foundpath foundPath 0 movedtemplate movedTemplateg d  docu  FCno  cpar %0!parse_location_placeholder_string .corecnte********  ctxt  cha 0errmsgerrMsg  cobj 0get_specified_tree 0move_to_section .sysodlogaskrTEXT$*k/,EOi/EO)k+EOPW XjvEOj j\(,[\[Zk\Z2&EO[\[Zk\Z2&,FWX hOk/EO)k+ EOf)l+EYj YhUU{ m  0update_template_properties   0duplicateditemduplicatedItem "0theplaceholdersthePlaceholders "0thereplacementstheReplacements 0thetasktheTask $0datedifferentialdateDifferential   0duplicateditemduplicatedItem "0theplaceholdersthePlaceholders "0thereplacementstheReplacements 0thetasktheTask $0datedifferentialdateDifferential 0thenotetheNote 0 thecommand theCommand   docu  FCno 00buildreplacementscriptbuildReplacementScript *0replaceplaceholdersreplacePlaceholders  from &0stripplaceholdersstripPlaceholders 0 replacetext replaceText  FCPsFCPa  FCPsJF*k/>,EO)m+EO)m+O)l EO)l+EO,FO,FOUU| 0duplicate_item 0 selecteditem selectedItem "0theplaceholdersthePlaceholders 0theprojectnametheProjectName "0thereplacementstheReplacements 0 selecteditem selectedItem "0theplaceholdersthePlaceholders 0theprojectnametheProjectName "0thereplacementstheReplacements 0 thestartdate theStartDate 0 theduedate theDueDate 0duplicateditemduplicatedItem $0datedifferentialdateDifferential 0thetasktheTask 0msg 0numw+=EG  docu  FCDs  FCDd  insh  FCSX  insl .coreclon********  msng *0getdatedifferentialgetDateDifferential 0notify  FCrt 0msg  errn 0num\ .sysobeepnulllong  errn*k/,EO,EO*i/4l O*i/EO)l+ EOhYhY$)l+ EOhYhYEO)%%bm+Oa,EkvEW%Xa kvEY*j O)alOavUU} 0project_validity_check 0 selecteditem selectedItem 0 selecteditem selectedItem 0theprojectnametheProjectName 0thenotetheNote "0theplaceholdersthePlaceholders ,0theplaceholderstringthePlaceholderString  docu  FCdw  pnam  FCno  cpar 00parseplaceholderstringparsePlaceholderString .corecnte********  mesS  ret  as A  EAlTwarN  btns  dflt .sysodisAaleRTEXT*k/*k/,EO,EOjvEOi/EO)k+EWXhOj jK%%%b%%b%a%b%a%b%aaaakvaka OfYhOlvUUU~ %0!parse_location_placeholder_string 0 thestring theString 0 thestring theString 0olddelimoldDelim 0 firstparse firstParse 0 theresult theResult  ascr  txdl  citm  rest &0cleanplaceholderscleanPlaceholders6,EOb,FO-,EOb ,FO*jvl+EO,FO7 0get_specified_tree 0treepathtreePath 0treepathtreePath 0 currenttree currentTree 0 treepathparts treePathParts 0i 0errmsgerrMsg O  docu  FCdw  FCSt  OTtr  pnam 0get_path_parts .corecnte********  cobj 0errmsgerrMsghd*k/Y*k/Q*,k/[,\Z81EO)k+EO3kj khk/[,\Z/81EW X fOP[OYUUOU 0move_to_section 0treepathtreePath 0 newtemplate newTemplate~ 0treepathtreePath 0 newtemplate newTemplate 0 treepathparts treePathParts 0currentsectioncurrentSection 0i ~0errmsgerrMsg}|{zyxwvutsr } docu |0get_path_parts { insh z FCSX y pnam x cobj w insl v.coremovenullobj ut s.corecnte******** r0errmsgerrMsg*k/)k+EO0*k/[,\Zk/814l O*k/[,\Zk/81EW X fOLlj kh0k/[,\Z/814l Ok/[,\Z/81EW X fOP[OYOi/4l UOUq pon q0get_path_partspmml l0treepathtreePathokji k0treepathtreePath j0 pathparts pathParts i0ihgfe h 0explode g.corecnte******** f cobj e0trimn0)fm+EO kj kh)/k+/F[OYOd6cba d 0explodec``_^] _ 0 delimiter ^0sometextsomeText ] 0limitb\[ZYX \ 0 delimiter [0sometextsomeText Z 0limit Y0prevtidsprevTIDs X 0output WVUTSRQP W long V ascr U txdl T citm S cobjRQ P.corecnte********a&EO,EO,FO-EOj-j[\[Zk\Zk2EYhW XjvEY/j k"[\[Zk\Z2[\[Zk\Zi2%%EYhO,FOONML O0trimNKKJ J0sMIHGF I0s H0l G 0started F0thisitemthisItem EDCBA@?>= E spac D ascr C txdl B citm A kocl @ cobj ?.corecnte******** > pcnt = TEXTLTkv,FO-EOkv,FOfEO3[l khj j %,FYeEYh[OYO&<;:9 <00parseplaceholderstringparsePlaceholderString;887 70 thestring theString:6543 60 thestring theString 50olddelimoldDelim 40 firstparse firstParse 30 theresult theResult210/. 2 ascr 1 txdl 0 citm / rest .&0cleanplaceholderscleanPlaceholders96,EOb,FO-,EOb,FO*jvl+EO,FO-;,+* -&0cleanplaceholderscleanPlaceholders,))(' (0thelisttheList ' 0accum+&%$ &0thelisttheList % 0accum $0 firstitem firstItem#"!  # cobj " citm ! cha .corecnte********  rest &0cleanplaceholderscleanPlaceholders*0replaceplaceholdersinchildrenreplacePlaceholdersInChildren  rest *0replaceplaceholdersreplacePlaceholders%jvhYhO*k/m+O*,m+ >0replaceplaceholdersinchildrenreplacePlaceholdersInChildren 0thetasktheTask 0 thecommand theCommand $0datedifferentialdateDifferential 0thetasktheTask 0 thecommand theCommand $0datedifferentialdateDifferential   pnam  TEXT 0 replacetext replaceText  FCDd 0 updatedate updateDate  FCDs  FCno  msng  FCac *0replaceplaceholdersreplacePlaceholdersUZ),&l+,FO),l+,FO),l+,FO,),&l+,FYhO)-m+  0 replacetext replaceText 0thetexttheText 0 thecommand theCommand 0thetexttheText 0 thecommand theCommand 0 quotedtext quotedText  strq .sysoexecTEXTTEXT,EO%%j EO 0 updatedate updateDate 0 originaldate originalDate $0datedifferentialdateDifferential 0 originaldate originalDate $0datedifferentialdateDifferential 0newdatenewDate  msng  bool &YhOEO$ &0stripplaceholdersstripPlaceholders  from 0thenotetheNote 0thenotetheNote 0 noteparts noteParts4  cpar .corecnte********  ctxt&-j kYhO[\[k/\/2EON 0notify 0thetitletheTitle 0thedescriptiontheDescription *0thenotificationkindtheNotificationKind 0thetitletheTitle 0thedescriptiontheDescription *0thenotificationkindtheNotificationKind k  appl  anot  dnot  iapp .registernullnull  name  titl  desc .notifygrnullnull51*bbbb O*b U .aevtoappnull**** k@S~~}| }0i |0j({zyxwvutsrqponmlkjihgfedcba`_^]\[ { docu z FCdw y FCcn x OTst w$0theselecteditemstheSelectedItems v.corecnte******** u FCSt t mesS s as A r EAlTwarNq p.sysodisAaleRTEXT o40theselecteditemsarevalidtheSelectedItemsAreValid n"0theplaceholdersthePlaceholders m cobj l valL k0 selecteditem selectedItem j0project_validity_check i*0theplaceholderstempthePlaceholdersTemp h 0theprojectnametheProjectName g*0thereplacementslisttheReplacementsList f"0getreplacementsgetReplacements e"0thereplacementstheReplacements d0 newtemplates newTemplates c0 thetasklist theTaskList b0duplicate_item a0 duplicateitem duplicateItem `0 newtemplate newTemplate _$0datedifferentialdateDifferential^ ]0update_template_properties \0move_new_template [ 0notifyA=*k/*k/*,-EOj k *,-EYhUOj k OhYhOeEOjvE`Okj kha/a,E`O)_k+EOfhYSak/E`O8k_j kh__a/ __a/%E`Yh[OYOal/E`OP[OYOjvE`O)_jvl+E`O_j jhYhO__%E`OjvE`OjvE`O~kj kha/a,E`O)____+E`O_ak/E`O_al/E`O__am/kv%E`O_a/E`O__kv%E`[OYO4k_j kh)_a/___a/_a +![OYO!k_j kh)_a/k+"[OYUO_j k)a#a$bm+%Y"_j k)a&a'bm+%YhOPUascr ޭ