<TITLE>Re: Applescript to help update the Engines folder after a TeXShop update</TITLE>
<FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:18pt'>Aloha,<BR>
<BR>
I’ll look into it. Thanks for pointing this out.<BR>
<BR>
Ramón<BR>
<BR>
<BR>
on 3/16/10 2:07 PM, Nathan Paxton [via MacOSX-TeX] at <a href="ml-node+4747362-112521027-49831@n2.nabble.com" target="_top" rel="nofollow" link="external">ml-node+4747362-112521027-49831@...</a> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:18pt'> Ramon, <BR>
<BR>
When I run this script, I get the following error: error "find: -exec: no terminating \";\" or \"+\"" number 1 for the line: <BR>
set command to "find ~/Library/TeXShop/Engines -name '*.engine' -type f -exec md5sum {} // ;" <BR>
<BR>
<BR>
How can I fix the script? <BR>
<BR>
Thanks in advance for your help. <BR>
<BR>
Best, <BR>
-Nathan <BR>
---------- <BR>
Nathan A. Paxton, Ph.D. <BR>
Lecturer <BR>
Dept. of Government, Harvard University <BR>
<BR>
napaxton AT fas DOT harvard DOT edu <BR>
<a href="http://www.fas.harvard.edu/~napaxton" target="_top" rel="nofollow" link="external">http://www.fas.harvard.edu/~napaxton</a><BR>
========================================================= <BR>
The most courageous act is still to think for yourself. Aloud. <BR>
-Coco Chanel <BR>
========================================================= <BR>
<BR>
On 25 Feb 2010, at 1:44 AM, RamÓn Figueroa-Centeno wrote: <BR>
<BR>
> <BR>
> Aloha, <BR>
> <BR>
> Below is an applescript to help integrate new engines after a TeXShop <BR>
> update. Options settable in the beginning of it. <BR>
> <BR>
> Now, if you are like me and don't want an extra copy of an active engine <BR>
> that really has not changed (MD5 sum and name are the same) in the Inactive <BR>
> folder then set "trashdups" to true, and they will be trashed (not deleted). <BR>
> Otherwise set it to false and they the duplicates will be labeled red in the <BR>
> Finder. <BR>
> <BR>
> Moreover, if you wish to replace old engines with new ones (same name but <BR>
> different MD5 sum), set "update" to true. Otherwise set it to false and have <BR>
> the old ones labeled orange and the new ones green. Now, here "old" and <BR>
> "new" can be relative terms, in the case that you, for example, have <BR>
> modified an engine and do not wish it to be "updated", then the old is new <BR>
> and the new is old. For that there is an ignore list, where you can place <BR>
> the names of the engines that you wish to be left alone (Herb Schultz, I <BR>
> believe, mentioned in another posting that he, for example, modifies the <BR>
> default engines at times, and would not like them to be "updated"). <BR>
> <BR>
> I suggest you try the script out first with both "trashdups" and "update" <BR>
> set to false and make a backup of the Engines folder, until we know it is <BR>
> really safe (no bugs or wrong assumptions). It works for me, but no <BR>
> guarantees. <BR>
> <BR>
> To use it copy and paste it from below into a new document in the "Script <BR>
> Editor". If you find it useful you can save it as a standalone application <BR>
> (or as a TeXShop Macro, I guess, but I have not tried it that way). <BR>
> <BR>
> Enjoy! <BR>
> <BR>
> RamÓn <BR>
> <BR>
> ------ <BR>
> <BR>
> -- Script to help organize new engines after a TeXShop update. <BR>
> -- Ramon Figueroa-Centeno (February 24, 2010) <BR>
> <BR>
> -- Trash duplicate (already installed) engines in the Inactive folder or <BR>
> just label them red <BR>
> property trashdups : false <BR>
> -- Replace "old" engines with "new" ones in the Inactive folder or just <BR>
> label the "old" ones orange <BR>
> -- (the new ones always get green). <BR>
> property update : false <BR>
> -- A list of the engines that you wish to "NOT" be trashed, e.g., "XeLaTeX" <BR>
> (not "XeLaTeX.engine"). <BR>
> -- The names are case sensitive! <BR>
> property ignore_list : {} <BR>
> <BR>
> -- Find all the engines in "/Library/TeXShop/Engines" (or subdirectories <BR>
> thereof) and compute their md5sum <BR>
> set command to "find ~/Library/TeXShop/Engines -name '*.engine' -type f <BR>
> -exec md5sum {} \\;" <BR>
> set candidates to paragraphs of (do shell script command) <BR>
> set engines to {} <BR>
> set md5sums to {} <BR>
> set names to {} <BR>
> repeat with p in candidates <BR>
> set md5sums to md5sums & {(characters 1 thru 32 of p) as string} <BR>
> set filepath to (characters 36 thru -1 of p) as string <BR>
> set engines to engines & {filepath} <BR>
> set basename to do shell script "basename " & quoted form of filepath & " <BR>
> .engine" <BR>
> set names to names & {basename} <BR>
> end repeat <BR>
> <BR>
> -- Assume that there are at most two of each engine, one active and/or one <BR>
> inactive. <BR>
> -- When there are two engines define the one in the Inactive folder as "new" <BR>
> and the other as old" <BR>
> <BR>
> set duplicates to {} <BR>
> set new_engines to {} <BR>
> set old_engines to {} <BR>
> repeat with i from 1 to (count of engines) - 1 <BR>
> repeat with j from i + 1 to count of engines <BR>
> if (item i of names) = (item j of names) then <BR>
> set e1 to item i of engines <BR>
> set e2 to item j of engines <BR>
> if (item i of md5sums) = (item j of md5sums) then <BR>
> if e1 contains "Inactive" and e2 does not contain "Inactive" then <BR>
> set duplicates to duplicates & {e1} <BR>
> else if e2 contains "Inactive" and e1 does not contain "Inactive" then <BR>
> set duplicates to duplicates & {e2} <BR>
> end if <BR>
> else <BR>
> if e1 contains "Inactive" and e2 does not contain "Inactive" then <BR>
> set new_engines to new_engines & {e1} <BR>
> set old_engines to old_engines & {e2} <BR>
> else if e2 contains "Inactive" and e1 does not contain "Inactive" then <BR>
> set new_engines to new_engines & {e2} <BR>
> set old_engines to old_engines & {e1} <BR>
> end if <BR>
> end if <BR>
> end if <BR>
> end repeat <BR>
> end repeat <BR>
> <BR>
> -- Finder labels <BR>
> property nolabel : 0 <BR>
> property red : 2 <BR>
> property orange : 1 <BR>
> property yellow : 3 <BR>
> property green : 6 <BR>
> property blue : 4 <BR>
> property purple : 5 <BR>
> property gray : 7 <BR>
> <BR>
> tell application "Finder" to activate <BR>
> <BR>
> -- unlabel all the engines in the folder Engines hierarchy <BR>
> repeat with f in engines <BR>
> set f to POSIX file f <BR>
> tell application "Finder" <BR>
> if the label index of file f is not in {nolabel, green} then <BR>
> set the label index of file f to nolabel <BR>
> end if <BR>
> end tell <BR>
> end repeat <BR>
> <BR>
> -- label or trash duplicates <BR>
> repeat with f in duplicates <BR>
> set fname to do shell script "basename " & quoted form of f & " .engine" <BR>
> set f to POSIX file f <BR>
> if trashdups and (fname is not in ignore_list) then <BR>
> --trash the inactive duplicate if it is not in the ignore list <BR>
> tell application "Finder" to move the file f to the trash <BR>
> else <BR>
> tell application "Finder" to set the label index of file f to red <BR>
> end if <BR>
> end repeat <BR>
> <BR>
> -- label or trash "old" engines <BR>
> repeat with f in old_engines <BR>
> set fname to do shell script "basename " & quoted form of f & " .engine" <BR>
> set f to POSIX file f <BR>
> if update and (fname is not in ignore_list) then <BR>
> --trash old engine if it is not the ignore list <BR>
> tell application "Finder" to move the file f to the trash <BR>
> else <BR>
> tell application "Finder" to set the label index of file f to orange <BR>
> end if <BR>
> end repeat <BR>
> <BR>
> -- label or activate "new" engines <BR>
> repeat with f in new_engines <BR>
> set fname to do shell script "basename " & quoted form of f & " .engine" <BR>
> set f to POSIX file f <BR>
> tell application "Finder" to set the label index of file f to green <BR>
> if update and (fname is not in ignore_list) then <BR>
> --activate new engine if the "old" one is not the ignore list <BR>
> tell application "Finder" <BR>
> move the file f to the folder "Engines" of the folder "TeXShop" of the <BR>
> folder "Library" of home without replacing <BR>
> end tell <BR>
> end if <BR>
> end repeat <BR>
> <BR>
> -- <BR>
> View this message in context: <a href="http://n2.nabble.com/Applescript-to-help-update-the-Engines-folder-after-a-TeXShop-update-tp4630928p4630928.html" target="_top" rel="nofollow" link="external">http://n2.nabble.com/Applescript-to-help-update-the-Engines-folder-after-a-TeXShop-update-tp4630928p4630928.html</a><BR>
> Sent from the MacOSX-TeX mailing list archive at Nabble.com. <BR>
> ----------- Please Consult the Following Before Posting ----------- <BR>
> TeX FAQ: <a href="http://www.tex.ac.uk/faq" target="_top" rel="nofollow" link="external">http://www.tex.ac.uk/faq</a><BR>
> List Reminders and Etiquette: <a href="http://email.esm.psu.edu/mac-tex/" target="_top" rel="nofollow" link="external">http://email.esm.psu.edu/mac-tex/</a><BR>
> List Archive: <a href="http://tug.org/pipermail/macostex-archives/" target="_top" rel="nofollow" link="external">http://tug.org/pipermail/macostex-archives/</a><BR>
> TeX on Mac OS X Website: <a href="http://mactex-wiki.tug.org/" target="_top" rel="nofollow" link="external">http://mactex-wiki.tug.org/</a><BR>
> List Info: <a href="http://email.esm.psu.edu/mailman/listinfo/macosx-tex" target="_top" rel="nofollow" link="external">http://email.esm.psu.edu/mailman/listinfo/macosx-tex</a><BR>
> <BR>
<BR>
----------- Please Consult the Following Before Posting ----------- <BR>
TeX FAQ: <a href="http://www.tex.ac.uk/faq" target="_top" rel="nofollow" link="external">http://www.tex.ac.uk/faq</a><BR>
List Reminders and Etiquette: <a href="http://email.esm.psu.edu/mac-tex/" target="_top" rel="nofollow" link="external">http://email.esm.psu.edu/mac-tex/</a><BR>
List Archive: <a href="http://tug.org/pipermail/macostex-archives/" target="_top" rel="nofollow" link="external">http://tug.org/pipermail/macostex-archives/</a><BR>
TeX on Mac OS X Website: <a href="http://mactex-wiki.tug.org/" target="_top" rel="nofollow" link="external">http://mactex-wiki.tug.org/</a><BR>
List Info: <a href="http://email.esm.psu.edu/mailman/listinfo/macosx-tex" target="_top" rel="nofollow" link="external">http://email.esm.psu.edu/mailman/listinfo/macosx-tex</a><BR>
<BR>
<BR>
<HR ALIGN=CENTER SIZE="1" WIDTH="100%"NOSHADE><FONT COLOR="#666666">View message @ <a href="http://n2.nabble.com/Applescript-to-help-update-the-Engines-folder-after-a-TeXShop-update-tp4630928p4747362.html" target="_top" rel="nofollow" link="external">http://n2.nabble.com/Applescript-to-help-update-the-Engines-folder-after-a-TeXShop-update-tp4630928p4747362.html</a> <BR>
To unsubscribe from Applescript to help update the Engines folder after a TeXShop update, click here <<a target="_top" rel="nofollow" link="external"><Link Removed></a>> . <BR>
</FONT><BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:18pt'><BR>
-- <BR>
<BR>
Ramón M. Figueroa-Centeno, Ph.D.<BR>
Associate Professor<BR>
<BR>
Mathematics Department<BR>
University of Hawaii at Hilo<BR>
College Hall 4-A<BR>
200 W. Kawili St.<BR>
Hilo, HI 96720-4091<BR>
<BR>
(808) 974-7387 (office)<BR>
(808) 933-3473 (fax)<BR>
<BR>
<a href="http://www2.hawaii.edu/~ramonf/" target="_top" rel="nofollow" link="external">http://www2.hawaii.edu/~ramonf/</a><BR>
</SPAN></FONT>
<br><hr align="left" width="300">
View this message in context: <a href="http://n2.nabble.com/Applescript-to-help-update-the-Engines-folder-after-a-TeXShop-update-tp4630928p4747409.html">Re: Applescript to help update the Engines folder after a TeXShop update</a><br>
Sent from the <a href="http://n2.nabble.com/MacOSX-TeX-f576846.html">MacOSX-TeX mailing list archive</a> at Nabble.com.<br>