Re: Portable Notebooks and Filenames[]
- To: mathgroup at smc.vnet.net
- Subject: [mg57894] Re: Portable Notebooks and Filenames[]
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Sun, 12 Jun 2005 04:34:15 -0400 (EDT)
- Organization: Uni Leipzig
- References: <d8e4e7$gik$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, a) at least Mathematica under Windows understand "c:/YourFiles" b) ToFileName[] will construct the file name from the directory names and the file without the explicit usage of "/" or "\" Regards Jens "frank" <frank at kuesterei.ch> schrieb im Newsbeitrag news:d8e4e7$gik$1 at smc.vnet.net... > Hi, > > in our group we are using Mathematica both on > Windows and on Linux (and > I'm about to convert a MacAddict to > Mathematica). However, we are > facing one problem with external file names. > > It is possible to use > > In[1]:= > SetDirectory["some/directory/subdirectory"]; > > (from a syntax point of view; of course the > beginning of the string will > be different, like ~/netdrive vs. w:) > > On the other hand, this works only on Linux: > > In[2]:=FileNames["subdir/*"] > > while on Windows, only this construct works: > > In[3]:=FileNames["subdir\\*"] > > (\ needs to be escaped because \* or nearly any > \<letter> combination > has some meaning). > > This is weird - first because Windows > understands the forward slash as a > directory separator, and second because it means > we have to do > search-replace orgies when trying a notebook on > a different OS. This > would not only happen in a preamble part, but we > even have some > functions that read all data in a subdirectory, > for a list of > subdirectories. > > Is there a way to write such expressions > portable? Is there, for > example, an internal variable "directory > separator" that could be used > in this string? Alternatively, if it's possible > to replace \\ by / (and > vice versa) by some string matching mechanism, > we could write a function > that does this if some boolean is set once in > the notebook, or even > depending on some internal variable that > indicates the OS? > > Regards, Frank > -- > Frank Küster > Inst. f. Biochemie der Univ. Zürich > Debian Developer >