Making a directory in an IDL routine. [message #10444] |
Thu, 04 December 1997 00:00  |
D.Kennedy
Messages: 26 Registered: January 1997
|
Junior Member |
|
|
An usual request -
Does anyone know how to make a directory from inside an IDL
routine? I know its odd, but its the best way to organise
a huge save set that'll be generated.
(And better yet, how to check if such a directory already
exists).
I imagine that this is machine dependant - UNIX answers
only needed.
--
David Kennedy, Dept. of Pure & Applied Physics, Queen's University of Belfast
Email: D.Kennedy@Queens-Belfast.ac.uk | URL: http://star.pst.qub.ac.uk/~dcjk/
My .sig was so clever that it actually escaped!
|
|
|
Re: Making a directory in an IDL routine. [message #10521 is a reply to message #10444] |
Sun, 07 December 1997 00:00   |
gurman
Messages: 82 Registered: August 1992
|
Member |
|
|
In article <34870691.0@cfanews.harvard.edu>, rpete@ascda3.harvard.edu
(Pete Ratzlaff) wrote:
> David Kennedy (D.Kennedy@qub.ac.uk) wrote:
>> An usual request -
>> Does anyone know how to make a directory from inside an IDL
>> routine? I know its odd, but its the best way to organise
>> a huge save set that'll be generated.
>
>> (And better yet, how to check if such a directory already
>> exists).
>
>> I imagine that this is machine dependant - UNIX answers
>> only needed.
>
> 'spawn' can do both of these
>
> 1. To check if a directory exists:
> IDL> dir='/home/me/mydir'
> IDL> spawn, 'ls -a '+dir, result
This is better than findfile? I understand the latter has trouble with
UFS directories with lots of entries, but still....
>
> Now, check the length of RESULT[0]. If it is zero, then
> DIR doesn't exist, otherwise DIR does exist.
>
> 2. To create a directory
> IDL> spawn,'mkdir '+dir
>
> This may not be elegant, but it works.
The best part about findfile is that it's (relatively) OS-independent,
and even has a keyword, COUNT, that is ero indicates there are no files
meeting the filepath specification in the argument:
IDL> result = FINDFILE('<filespec>', COUNT = count)
e.g.
IDL> result = FINDFILE('/home/me/mydir', COUNT = count)
For some bizarre reason, the Digital UNIX version of IDL 5.0.3 cannot
resolve "~<homedirectory>" in findfile --- you have to state explicitly
where the home directory lives.
FWIW,
Joe Gurman
--
Joseph B. Gurman / NASA Goddard Space Flight Center/ Solar Data Analysis Center / Code 682 / Greenbelt MD 20771 USA / gurman@gsfc.nasa.gov / gurman@ari.net
| Federal employees are still prohibited from holding opinions while at work. Any opinions expressed herein must therefore be someone else's. | SPAMbot trap: abuse@127.0.0.1
|
|
|
Re: Making a directory in an IDL routine. [message #10559 is a reply to message #10444] |
Mon, 15 December 1997 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Joseph B. Gurman wrote:
[...]
> For some bizarre reason, the Digital UNIX version of IDL 5.0.3 cannot
> resolve "~<homedirectory>" in findfile --- you have to state explicitly
> where the home directory lives.
Nope, you can also use expand_path as I learned a couple of months ago
:-)
Martin.
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
|
|
|