Get path from filename

E

Eli

What's the easiest way to get the path from a fully pathed filename?
For instance, given

C:\Some Directory\And Another Directory\My Word Document.doc

I'd like (with or without the trailing slash)

C:\Some Directory\And Another Directory\
 
What's the easiest way to get the path from a fully pathed filename?
For instance, given

C:\Some Directory\And Another Directory\My Word Document.doc

I'd like (with or without the trailing slash)

C:\Some Directory\And Another Directory\
Well, if reading it isn't good enough...how
about "cd" <enter>?
 
Eli said:
Doh! Posted to the wrong group. :)

You could buy MKS toolkit or download cygwin for free. It's tricky to
get cygwin installed, though. Both of these should come with "basename"
and "dirname" programs which do what you want.

But both of those are overkill. If you can program, look up the basename
and dirname functions and try to write them yourself.

Doh! Wrong group! :) Oh well, you got an answer anyway.
 
Eli said:
What's the easiest way to get the path from a fully pathed filename?
For instance, given

C:\Some Directory\And Another Directory\My Word Document.doc

I'd like (with or without the trailing slash)

C:\Some Directory\And Another Directory\

Go to the Microsoft web site and download Windows Services for Unix and
then use the basename utility. MS used to charge $99 for the package,
but now it is free.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
13,889
Messages
67,365
Members
7,364
Latest member
Cimarron49

Latest Threads

Back
Top