Get path from filename

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\

Reply to
Eli
Loading thread data ...

Doh! Posted to the wrong group. :)

Reply to
Eli

Well, if reading it isn't good enough...how about "cd" ?

Reply to
CompUser

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.

Reply to
Tom Reingold

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.

Reply to
kstahl

% echo `pwd`"/filename"

florian

Reply to
Florian Feuser /FFF/

MotorsForum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.