Re: mkdir? [message #23747] |
Wed, 14 February 2001 09:48 |
Christopher W. O'Dell
Messages: 20 Registered: February 2001
|
Junior Member |
|
|
Thanks Jeff. I'm using 5.2 still so I can't use that new
command. The spawn trick works in windows as well,
with no modifications necessary.
-Chris
Jeff Jones wrote:
> "Christopher W. O'Dell" wrote:
>>
>> Is there anyway to create a directory in your OS from within
>> IDL?
>> I keep running into problems using the SAVE function, when I
>> have forgotten to create the directory to which I am
>> saving. I just want to add a line of code that checks if
>> the directory exists, and if it doesn't it makes the
>> directory.
>> BTW, I'm running on a Windows platform (your are welcome to
>> make fun of me at this point...)
>>
>> Thanks,
>> Chris O'Dell
>>
>> UW-Madison Physics Dept.
>
> Here is what I do under Unix in IDL 5.1:
>
> dir = '/the/directory/im/looking/for/'
>
> ; Create the directory, if necessary.
> check = findfile( dir, count=direxists )
> if (direxists eq 0) then spawn, 'mkdir '+dir
>
> I am sure something equivalent can be done in Windows.
>
> Jeff.
|
|
|
Re: mkdir? [message #23752 is a reply to message #23747] |
Wed, 14 February 2001 07:19  |
Jeff Jones
Messages: 2 Registered: February 2001
|
Junior Member |
|
|
"Christopher W. O'Dell" wrote:
>
> Is there anyway to create a directory in your OS from within
> IDL?
> I keep running into problems using the SAVE function, when I
> have forgotten to create the directory to which I am
> saving. I just want to add a line of code that checks if
> the directory exists, and if it doesn't it makes the
> directory.
> BTW, I'm running on a Windows platform (your are welcome to
> make fun of me at this point...)
>
> Thanks,
> Chris O'Dell
>
> UW-Madison Physics Dept.
Here is what I do under Unix in IDL 5.1:
dir = '/the/directory/im/looking/for/'
; Create the directory, if necessary.
check = findfile( dir, count=direxists )
if (direxists eq 0) then spawn, 'mkdir '+dir
I am sure something equivalent can be done in Windows.
Jeff.
|
|
|
Re: mkdir? [message #23754 is a reply to message #23752] |
Wed, 14 February 2001 08:25  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Christopher W. O'Dell writes:
> Is there anyway to create a directory in your OS from within
> IDL?
You can use the File_MkDir command that was introduced
in IDL 5.4.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: mkdir? [message #23755 is a reply to message #23752] |
Tue, 13 February 2001 19:17  |
Wayne Landsman
Messages: 117 Registered: January 1997
|
Senior Member |
|
|
"Christopher W. O'Dell" wrote:
> Is there anyway to create a directory in your OS from within
> IDL?
> I keep running into problems using the SAVE function, when I
> have forgotten to create the directory to which I am
> saving. I just want to add a line of code that checks if
> the directory exists, and if it doesn't it makes the
> directory.
> BTW, I'm running on a Windows platform (your are welcome to
> make fun of me at this point...)
If you have V5.4 you can use FILE_TEST( /DIR) to test if a directory
exists, and FILE_MKDIR to create a directory. If you have an earlier
IDL version you can try to CD to the directory and catch any errors (as
in http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/system/is_d ir.pro)
and SPAWN to create a directory.
Wayne
Landsman
landsman@mpb.gsfc.nasa.gov
|
|
|