[OS X TeX] Applescript in TS
Nestor Aguilera
aguilera at santafe-conicet.gov.ar
Mon Nov 7 20:49:38 CET 2011
On 7 Nov 2011, at 14:44, Themis Matsoukas wrote:
> Claus,
>
> The script does not recognize blanks in the file name. I gives the applescript error:
>
> "The files /Users/themis/WorkStuff/Classes/ChE, /220/Homework/_hw-collection, and /[2011]/problem-dbase/ch7_mix_steam_1/problem.tex do not exist."
>
> The script has broken the file name into three strings by cutting where the blanks are. The correct file name, as read by dropping the file on the terminal, is
>
> /Users/themis/WorkStuff/Classes/ChE\ 220/Homework/_hw-collection\ \[2011\]/problem-dbase/ch7_mix_steam_1/problem.tex
>
> Is there easy easy fix for that?
>
> Themis
I am in Snow Leopard, so this may not apply, but I have the following inside an AppleScript for using Sneep's TeX unix scripts with TextWrangler:
(* some previous things *)
tell application "TextWrangler"
set name to file of the first text document of first text window
save name
end tell
set frontdoc to the POSIX path of file (name as Unicode text)
set fbase to do shell script ("basename " as Unicode text) & the quoted form of frontdoc
set fdir to do shell script ("dirname " as Unicode text) & the quoted form of frontdoc
set fbasenew to replace_chars(fbase, " ", "\\ ")
set fdirnew to replace_chars(fdir, " ", "\\ ")
(* some more things *)
So the trick is to use "replace_chars" to replace spaces with "\ ". Of course, this doesn't work for accents.
Cheers,
Nestor
More information about the macostex-archives
mailing list