VOGONS

Common searches


CD /D option

Topic actions

First post, by pmennen

User metadata
Rank Newbie
Rank
Newbie

The CD command in modern versions of DOS have a /D option which also changes the current drive. So for example "CD /D F:\abc" would be equivalent to the two commands "CD F:\abc" and "F:".

Unfortunately for some reason DosBox doesn't implement the /D option for the CD command. I really need it however, or some other command or batch file that will do this in a single command. (The reason I need this is complicated but boils down to the fact that in a particular environment I have a string containing the path, but I don't have a separate string containing just the drive letter).

In searching for a solution, I found a very old dos utility called CWD which is the equivalent of CD /D. I'll use it if I have to but it has the significant drawback that it will not handle long file names like CD will.

One idea I had is too see if there was any utility that could extract the first 2 characters of a string argument. Suppose I found such a program (say called FRST2). Then I could make my wanted batch file as follows:

CD %1
FRST2 %1

Since the first two characters of the argument will always be the drive letter followed by a colon (in my situation) this would work for me.

Seems like there might be a function similar to FRST2 although so far I couldn't find one. Could something like that be built out of some batch scripting language?

Thanks in advance for any ideas you may have for me.
~Paul

Reply 2 of 6, by VileR

User metadata
Rank l33t
Rank
l33t

what do you mean by "modern versions of DOS"? I'm pretty sure the /D switch did not exist in MS-DOS 6.22, which was the last full-fledged MS-DOS; of course, if I'm wrong then I stand corrected.

the Command Prompt in Windows XP does have /D, but that's not DOS.

anyway, you're saying the CWD utility is problematic because it lacks long filename support... DOSBox itself does not support LFN anyway, so it uses 8.3 names for all files internally.

[ WEB ] - [ BLOG ] - [ TUBE ] - [ CODE ]

Reply 4 of 6, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Unfortunately for some reason DosBox doesn't implement the /D option for the CD command.

I'm not surprised that some people would be *pleased* if DOSBox could do everything the Windows command prompt does; but I'm still amazed when they are not only disappointed, but also *puzzled* that it doesn't...

Reply 6 of 6, by pmennen

User metadata
Rank Newbie
Rank
Newbie

> Why can't you just do
> F:
> CD abc

I'm calling dosbox from a button in another program and I don't have the drive letter. All I have is a string that contains the complete path, i.e. "F:\abc" in this example. (That's why I was looking for a program that could extract the first two characters of a string, since that would give me the drive letter and then I could do as you suggested).

>what do you mean by "modern versions of DOS"? I'm pretty sure the /D >switch did not exist in MS-DOS 6.22 ...

Oops, I stand corrected. I just googled the CD command and saw the /D and jumped to the wrong conclusion.

> anyway, you're saying the CWD utility is problematic because it
> lacks long filename support... DOSBox itself does not support
> LFN anyway, so it uses 8.3 names for all files internally.

Ah, I see that now. I suspect that LFN didn't make sense anyway for what dosbox was designed for. LFN would be useful for me, but despite that I will use dosbox since it allows me to run some of my old dos utilities that I can't run from the windows command prompt. So I guess I already have the optimal solution (the CWD utility) and I don't need to look for a different way. Thanks "VileRancour" for straightening me out.

~Paul