VOGONS

Common searches


[DOS]Changing drive and directory in one line?

Topic actions

  • This topic is locked. You cannot reply or edit posts.

First post, by clueless1

User metadata
Rank l33t
Rank
l33t

Just curious if there's a faster way than:
C:\>d:
D:\>cd lol
D:\LOL>

Last edited by clueless1 on 2016-08-13, 00:13. Edited 1 time in total.

The more I learn, the more I realize how much I don't know.
OPL3 FM vs. Roland MT-32 vs. General MIDI DOS Game Comparison
Let's benchmark our systems with cache disabled
DOS PCI Graphics Card Benchmarks

Reply 1 of 18, by clueless1

User metadata
Rank l33t
Rank
l33t

Holy smokes, as I clicked Submit, I thought "I wonder if the pipe command works in MS-DOS?"
It worked on the first try. :)
C:\>d:|cd lol
D:\LOL>

Cool! My bit of linux experience ended up helping me in MS-DOS. Who knew?

The more I learn, the more I realize how much I don't know.
OPL3 FM vs. Roland MT-32 vs. General MIDI DOS Game Comparison
Let's benchmark our systems with cache disabled
DOS PCI Graphics Card Benchmarks

Reply 3 of 18, by keenmaster486

User metadata
Rank l33t
Rank
l33t

Depends on whether or not your keyboard has a very large enter key next to a very small backslash key (and the pipe key) like mine does.

I'm constantly doing things like:

xcopy d:\A_LOT_OF_FILES c: [here I accidentally press enter while attempting to press backslash]

Result:

dir c:

C:\ contains too many files for DOS to display. System halted.

Me:

images?q=tbn:ANd9GcRgrhe6q2c33LG0Wue5FHm6n81fL1qYwrzBilNTfnkTDyr3OElQ

World's foremost 486 enjoyer.

Reply 4 of 18, by Gemini000

User metadata
Rank l33t
Rank
l33t

The reason why the cd command doesn't change the drive is because you can actually use it to change the active directory of the non-active drive!

For instance:

D:\> c:
C:\> cd d:\stuffs
C:\> d:
D:\STUFFS>

;)

--- Kris Asick (Gemini)
--- Pixelmusement Website: www.pixelships.com
--- Ancient DOS Games Webshow: www.pixelships.com/adg

Reply 5 of 18, by clueless1

User metadata
Rank l33t
Rank
l33t

keenmaster: 🤣!

One of the commands I somehow remembered from back in the day was for copying a directory and all its contents to another location:
xcopy c:\games\lol\*.* d:\lol /s
I just love when I forget to include the destination folder (thinking somehow that will get made on its own):
xcopy c:\games\lol\*.* d: /s
same result as you.
/ragequit

The more I learn, the more I realize how much I don't know.
OPL3 FM vs. Roland MT-32 vs. General MIDI DOS Game Comparison
Let's benchmark our systems with cache disabled
DOS PCI Graphics Card Benchmarks

Reply 6 of 18, by j7n

User metadata
Rank Newbie
Rank
Newbie

It's annoying how the Backslash key gets a different position in many keyboards, and yet it is essential for typing in commands on DOS/Windows.

https://www.youtube.com/watch?v=JOj2WhkEXtA

I'm used to the key being below Enter. When I am at strange computer, I end up pushing the Shift key and nothing happens. The worst case is when the backslash key is difficult to distinguish by touch from Backspace, Square Bracket, or indeed Enter. In the picture above (not my actualy kbd), all keys in the area have a clearly distinct shape.

Reply 7 of 18, by clueless1

User metadata
Rank l33t
Rank
l33t

Ha. I'm used to the backslash being ABOVE a normal-width Enter key. But I also have the layout you prefer. I use the layout-you-prefer on my Windows PCs, and the narrow-Enter-with-backslash-above-it for my DOS PCs.

The more I learn, the more I realize how much I don't know.
OPL3 FM vs. Roland MT-32 vs. General MIDI DOS Game Comparison
Let's benchmark our systems with cache disabled
DOS PCI Graphics Card Benchmarks

Reply 9 of 18, by SquallStrife

User metadata
Rank l33t
Rank
l33t

I dunno about plain MS-DOS, but in Windows there are a couple of options.

C:\>PUSHD D:\LOL
D:\LOL>SOMETHING

YAY Something!

D:\LOL>POPD
C:\>_

or

C:\>CD /D D:\LOL
D:\LOL>_
Gemini000 wrote:

The reason why the cd command doesn't change the drive is because you can actually use it to change the active directory of the non-active drive!

This is also true.

VogonsDrivers.com | Link | News Thread

Reply 10 of 18, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++

PUSHD is not intrinsic to MS-DOS COMMAND.COM. Neither is POPD. NTVDM implements it, so you can use it in Win2k and later. 4dos implements it, so you can substitute the command interpreter to gain this functionality. I have a batch file which accomplishes the task.

All hail the Great Capacitor Brand Finder

Reply 11 of 18, by Rekrul

User metadata
Rank Member
Rank
Member
Gemini000 wrote:
The reason why the cd command doesn't change the drive is because you can actually use it to change the active directory of the […]
Show full quote

The reason why the cd command doesn't change the drive is because you can actually use it to change the active directory of the non-active drive!

For instance:

D:\> c:
C:\> cd d:\stuffs
C:\> d:
D:\STUFFS>

😉

If it was me, I would have included an option to do that while making the optionless version switch to the drive and go into the directory, like you'd expect. It often seems like MS programmers went out of their way to make things as unintuitive as possible.

A while back I wanted to write a batch file to perform multiple operations on all files of a certain type, but I couldn't make it work properly. I was trying to manipulate the filenames using variables and they never contained the values that I expected. I had to ask on the net to learn that variable inside a For loop need to use Delayed Expansion. To be honest, I still don't understand exactly what it does or why anyone would need it to function that way. Regardless, it amazes me that anyone thought it would be a good idea to make this the default way that variables are handled inside a loop, which runs contrary to every other programming language I've ever used. Make it an option, not the default!

I have this image of two programmers kicking back, smoking a joint, when one says to the other "I just had a great idea! Let's make variables inside a loop act completely different than they do outside the loop. People will go nuts trying to figure out why their scripts don't work and then we can tell them that it's a special condition where they have to do extra crap to make it work." Then they both look at each other for a few seconds before busting up laughing.

Reply 13 of 18, by SquallStrife

User metadata
Rank l33t
Rank
l33t
Rekrul wrote:

If it was me, I would have included an option to do that while making the optionless version switch to the drive and go into the directory, like you'd expect. It often seems like MS programmers went out of their way to make things as unintuitive as possible.

"like you'd expect" varies though.

Something so fundamental like CHDIR would have been implemented to reflect the behaviour of a contemporary, probably CP/M. Digital Research did it a particular way because it met a certain requirement, or was easier to implement in code, or some such, so naturally DOS would have followed, and the rest is history.

Rekrul wrote:

Regardless, it amazes me that anyone thought it would be a good idea to make this the default way that variables are handled inside a loop, which runs contrary to every other programming language I've ever used. Make it an option, not the default!

Batch files are barely a programming language.

It makes more sense when you understand just how rudimentary CMD really is.

FOR is just a kludge that generates lines and puts them on the stack. All the variables are evaluated at the moment FOR is called, unless of course you use delayed expansion.

VogonsDrivers.com | Link | News Thread

Reply 14 of 18, by clueless1

User metadata
Rank l33t
Rank
l33t

I've been using the pipe command the past few days and it's becoming second nature. Here's my one-liner for running Lands of Lore on D: after I start the PC:
C:\>d:|cd lol|lolcd

The more I learn, the more I realize how much I don't know.
OPL3 FM vs. Roland MT-32 vs. General MIDI DOS Game Comparison
Let's benchmark our systems with cache disabled
DOS PCI Graphics Card Benchmarks

Reply 15 of 18, by gdjacobs

User metadata
Rank l33t++
Rank
l33t++
Errius wrote:

The old PC Magazine utilities include POPDIR.COM and PUSHDIR.COM (by John Friend) which I still use in DOS environments, including DOSBox.

Nice! I'll look in my set.

All hail the Great Capacitor Brand Finder

Reply 16 of 18, by VileR

User metadata
Rank l33t
Rank
l33t
SquallStrife wrote:

Something so fundamental like CHDIR would have been implemented to reflect the behaviour of a contemporary, probably CP/M. Digital Research did it a particular way because it met a certain requirement, or was easier to implement in code, or some such, so naturally DOS would have followed, and the rest is history.

CP/M at the time didn't have a hierarchical filesystem - CHDIR, etc. (down to the names) were borrowed from Unix like a lot of other improvements introduced in DOS 2.0 (MORE, SORT, piping, console redirection, etc). Specifically from Xenix, which was a successful MS product, and at the time DOS 2.0 was seen as part of a roadmap towards merging it into Xenix.
It's little-known that even the UNIX "/dev/" construct could be used in DOS >2 to access 'device files', except of course it was modified to "\DEV\". 😉

Errius wrote:

The old PC Magazine utilities include POPDIR.COM and PUSHDIR.COM (by John Friend) which I still use in DOS environments, including DOSBox.

Heh, I actually rolled my own specifically for DOSBox... except that mine aren't very useful since you can't 'stack' paths (only one is remembered at a time).

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

Reply 18 of 18, by keenmaster486

User metadata
Rank l33t
Rank
l33t
Davros wrote:

"C:\ contains too many files for DOS to display. System halted."

Dir c: /p

The result of this:

Bill Gates wrote:

I already told you that C:\ contains too many files! You moron! Upgrade your 486 to Windows 10 now and then it will work.

World's foremost 486 enjoyer.