[OS X TeX] Which one is forbidden : or /? Subtleties of dealing with file names in TeXShop Macros

Ramón Figueroa-Centeno ramonf at hawaii.edu
Mon May 31 03:47:37 EDT 2010


Which one is forbidden : or /?

If you try to name a file in the Finder and use a colon (:) in its name then
you will get a warning about this being forbidden. This has been the way
since the beginnings of the Macintosh (my memory of this only goes back to
1985), as colons are used as delimiters in paths to files. Now, you can name
a file in the Finder using forward slashes (/). However, Mac OS X is a front
end for UNIX, where forward slashes are forbidden in file names, right? So
what Apple did was the following compromise, if you name a file in the
Finder with forward slashes then internally those are replaced by colons.
For example, if you have a file in the Finder named “/data/.tex” and then
you peek at it in the Terminal you will see that its name is actually

So If you are referring to such a file in an Applescript beware of this

To ses this for yourself, create a document in TeXShop named /data/.tex (do
not hide the file extension) and run the following script form the
Applescript Editor:

tell application "TeXShop"
	set POSIX_path to path of the front document
	set Mac_name to (name of the front document) as string
end tell
tell me
	set POSIX_name to do shell script "basename '" & POSIX_path & "'"
	display dialog POSIX_name & return & Mac_name
end tell

You should get:


Now, go to the Finder, get info for /data/.tex and then click "Hide
extension". Run the script again. Now, you get:


So imagine that you have a script that takes UNIX path and from there it
gets the name of the document and from there starts to do other stuff. Such
a situation arises when you tell TeXShop to open a document, to which you
refer by its path, and then work with the document to which you refer by its
"Finder" name. Then you have to be careful to change in the name every ":"
to "/", try to access the file with its extension (e.g., .tex) using a "try"
statement and  "on error" try to access it without the extension.


View this message in context: http://macosx-tex.576846.n2.nabble.com/Which-one-is-forbidden-or-Subtleties-of-dealing-with-file-names-in-TeXShop-Macros-tp5120843p5120843.html
Sent from the MacOSX-TeX mailing list archive at Nabble.com.

More information about the MacOSX-TeX mailing list