[OS X TeX] Re: Applescript to help update the Engines folder after a TeXShop update

Ramón Figueroa-Centeno ramonf at hawaii.edu
Wed Mar 17 01:17:51 CET 2010


Aloha,

I¹ll look into it. Thanks for pointing this out.

Ramón


on 3/16/10 2:07 PM, Nathan Paxton [via MacOSX-TeX] at
ml-node+4747362-112521027-49831 at n2.nabble.com wrote:

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

-- 

Ramón M. Figueroa-Centeno, Ph.D.
Associate Professor

Mathematics Department
University of Hawaii at Hilo
College Hall 4-A
200 W. Kawili St.
Hilo, HI 96720-4091

(808) 974-7387 (office)
(808) 933-3473 (fax)

http://www2.hawaii.edu/~ramonf/


-- 
View this message in context: http://n2.nabble.com/Applescript-to-help-update-the-Engines-folder-after-a-TeXShop-update-tp4630928p4747409.html
Sent from the MacOSX-TeX mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/macostex-archives/attachments/20100316/f73838c5/attachment.html>


More information about the macostex-archives mailing list