[OS X TeX] Search and replace in many files
Michael Sharpe
msharpe at ucsd.edu
Wed Sep 5 19:53:42 EDT 2012
On Sep 5, 2012, at 4:14 PM, Alain Schremmer wrote:
> As I was getting desperate, I started making the changes with the OgreKit by hand but there are lots and lots of files. Since the OgreKit can do it, I was wondering if an applescript could make the OgreKit do it---after I have entered the strings in the Ogrekit panel by hand.
>
> I googled a lot but that stuff is very hermetic. Could anyone suggest a list where I could ask?
>
> Hopeful regards
> --schremmer
>
>
>
> Here are the four search and replace that I need to make and that the Ogrekit does very nicely:
>
> =========================
> 1 Search string: (Copy full line)
>
> \ifthenelse{\boolean{Quiz?}}%
>
> Replace string: (Copy two full lines)
>
> %SSSSSSSSSSSS
> \ifthenelse{\boolean{Quiz?}}%
>
>
> =========================
> 2 Search string: (Copy only string)
>
> %SSSSSSSSSSSS - Begin CHECKABLE ITEM:
>
> Replace string: (Copy only string)
>
> %SSSSSSSSSSSS - Begin CHECKABLE ITEM:
> %
>
>
>
> =========================
> 3 Search string: (Copy two full lines)
>
> %SSSSSSSSSSSS
> \ifthenelse{\boolean{Quiz?}}%
>
> Replace string: (Copy all full lines)
>
> %SSSSSSSSSSSS
> \ifthenelse{\boolean{Workout?}}%
> {%begin Workout? true
> %ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss - Begin WORKOUT
> \UseProblem{\CheckableItem-w}%
> {%
> WORKOUTtext%
> }{%
> $a$%
> }{%
> $b$%
> }{%
> $c$%
> }{%
> $d$%
> }{%
> x%
> }{%
> WORKOUTdiscussion%
> }%
> %ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss - End WORKOUT
> }%end Workout? true
> {%begin Workout? false
> \ifthenelse{\boolean{Quiz?}}%
>
>
> =========================
> 4 Search string:
>
> }% end Quiz? false
> % SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS - End CHECKABLE ITEM
>
> Replace string:
>
> }% end Quiz? false
> }% end Workout? false
> % SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS - End CHECKABLE ITEM
>
You might find my replaceall applescripts useful for multifile search and replace, from
http://dl.dropbox.com/u/3825336/TeX/index.html
Michael
More information about the MacOSX-TeX
mailing list