comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: FILE_DIRNAME question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: FILE_DIRNAME question [message #45604 is a reply to message #45603] Mon, 19 September 2005 13:08 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth Bowman writes:

> Can anyone explain what I am doing wrong here?
>
> IDL> print, FILE_DIRNAME(['top', 'middle'], /MARK)
> ./ ./
> IDL> print, FILE_DIRNAME('/top/middle/', /MARK)
> /top/

No, I can't explain it, because I don't understand it.
I mucked around with it for awhile, then wrote my own,
which was more convenient for me, too, because I could
obtain the base filename, the directory name, and the file
extension all at once.

http://www.dfanning.com/programs/fsc_base_filename.pro

It works like this:

filename = '/top/middle/myfile.jpg'
b = FSC_Base_Filename(filename, Directory=d, Extension=)
Print, 'Directory: ', d
Print, 'Filename: ', b
Print, 'Extension: ', e

Or, in an IDL session.

IDL> filename = '/top/middle/myfile.jpg'
IDL> b = FSC_Base_Filename(filename, Directory=d, $
IDL> Extension=e, Path_Sep='/')
IDL> Print, 'Directory: ', d
Directory: /top/middle/
IDL> Print, 'Filename: ', b
Filename: myfile
IDL> Print, 'Extension: ', e
Extension: jpg

Or, as in your example:

IDL> filename = '/top/middle/'
IDL> b = FSC_Base_Filename(filename, Directory=d, $
IDL> Extension=e, Path_Sep='/')
IDL> Print, 'Directory: ', d
Directory: /top/middle/
IDL> Print, 'Filename: ', b
Filename:
IDL> Print, 'Extension: ', e
Extension:


The path separator is returned by PATH_SEP, but if you want to
make separate a UNIX path on a Windows machine, or visa versa,
you can specify what the path separator should be via a keyword.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Container/Holder Destruction
Next Topic: wildcard in "where" command

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:04:24 PDT 2025

Total time taken to generate the page: 0.32370 seconds