Episode: 3590
Title: HPR3590: Directory Commands
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3590/hpr3590.mp3
Transcribed: 2025-10-25 01:52:05

---

This is Hacker Public Radio Episode 3594 Friday, 6th of May 2022.
Today's show is entitled, Direct 3 Commands and is part of the series DOS it is hosted by OUCA
and is about 15 minutes long and carries a clean flag.
The summary is, more on DOS this time it is Direct 3 Commands.
This episode of HPR is brought to you by an honesthost.com.
Get 15% discount on all shared hosting with the offer code HPR15.
That's HPR15.
Better web hosting that's honest and fair at An Honesthost.com.
Hello, this is OUCA, welcoming you to another exciting episode in our DOS series.
And today I want to start taking a look at directory commands.
We saw in our last episode that DOS uses directories to organize the files on your disks.
And that means we need to use directory commands to create a structure to store our files
and to find the files we have stored there.
Now the commands we need are relatively few.
Some of them have alternatives.
So one command is called md, Michael David, that creates a new directory or sub directory.
Now that's short version of mkdir, which is in some senses maybe a little more intuitively
clear what that is.
You can use either one.
Similarly, there is an rd, which is to remove or delete a directory and that's short
for rmdir, and then there's cd, change directory, change from the current working directory
to another directory, or the longer version chdir.
So those three are ones where I think most people, once you get used to it, you're going
to use the short version.
Now there is a command called deltree, d-e-l-t-r-e-e, now that erases a directory including any
files or sub-directories it may contain.
Obviously, this could be a dangerous one.
And finally there is just d-i-r, which lists the contents of the current working directory.
Now, working with directories is pretty central to what you do in DOS.
So with the exception of deltree, all of these are internal commands, which means they're
contained within commands.com and therefore loaded into RAM and ready for use whenever
you boot, including from a boot disk.
There's no real difference whether you use the short two-letter version of those commands
or the longer version.
So I think for the rest of this tutorial I'm going to use the two-letter version and save
effort on my part as well.
So md, this command is the make directory, it creates a new directory or sub-directorie.
Now technically, root is the main directory, so every directory under it is a sub-directorie,
but I'm going to just talk about sub-directories because the question is where are you in your
path when this happens?
Now an optional argument for the md directory is path.
So you can, from the current working directory, make a directory somewhere else, but you'd
have to give the path to it.
Now if you don't give a path, then the sub-directorie is created within the current working sub-directorie.
So as an example, suppose I'm at the prompt and I type md space letters, L-E-T-T-E-R-S,
oh that would create a sub-directorie called letters.
If I was on the root of the C drive, when I did that, then the sub-directorie would have
the address C colon-back slash letters.
Now with a path included, you can create a sub-directorie anywhere.
So again, I could be in the root of the C drive.
So my prompt is C colon-back slash greater than, that's my prompt.
And I could type md space, C colon-back slash letters, back slash love, and that would create
that particular sub-directorie.
Now let's say you were in the C colon-back slash letters directory, then all you would need
to do is type md space love, and that would have the same effect.
So you only need path information if you want to create this directory someplace other
than your current working directory.
There are some limitations.
The length of a path specification cannot exceed 63 characters, including the backslashes.
So that's one of the limits that you're going to have here.
Now the next command, RD, that removes a sub-directorie.
Now the sub-directorie must be empty at this point.
If it contains files and or sub-directories of the sub-directorie, then you'll get an error
message.
This also has an optional path argument with the same syntax as the md command.
Now note that you cannot remove the current working directory.
To do this, you have to change directories to the parent first and then remove the sub-directorie.
Now the RD command can sometimes be a little confusing because of the safeguards that
DOS builds into the command.
The idea that you cannot delete a sub-directorie that has contents, for instance, is a safety
measure.
Now Dell3 gets around this, but is a dangerous command for precisely that reason.
Now how can you tell if a sub-directorie is empty?
Just use the DIR command to display its contents.
Now CD, this is the change directory.
This command changes the current working sub-directorie to another sub-directorie.
Imagine a computer with the following directory structure.
You have a hard drive, C colon, backslash, and then within it we have a sub-directorie
that is called letters, and then under that is a couple of sub-directories.
One is called love, and one is called business, so I've got two kinds of letters here.
Then equivalent to the letters directory at the same level, I might have one called memos,
and then under that I've got two sub-directories, school and internet.
So let's say right now I'm in the directory C colon, backslash, letters, backslash, love.
Now if I want to change that to C colon, backslash, letters, backslash, business, I need
to specify the path.
So at the prompt I could, and my prompt at this point would say C colon, backslash, letters,
backslash, love, backslash, greater than.
That's my prompt, because that's my current working directory.
I could type in CD, space, C colon, backslash, letters, backslash, business.
That would change me to the business sub-directorie.
Now let's say my current working directory was C colon, backslash, letters, and I want
to go to C colon, backslash, letters, backslash, business.
Well in this case I don't need to use the path because the default is always to go downwards
in the directory tree.
So all I would have to do is give the command CD, space, business, and it would take
me there.
Now you can use shortcuts, there's a number of them with the change directory command.
CD, backslash, will take you back to the root directory from wherever you are.
CD, period, period, will take you to the parent sub-directorie of the current working sub-directorie.
So you could do a two-step process.
So again let's say my prompt is C colon, backslash, letters, backslash, love, backslash,
greater than sign.
That's my prompt, that's telling me my current working directory.
If I do CD, period, my current working directory, it takes me up to letters as my current working
directory.
Then I could type the command CD, space, business, and go into the business.
So it's a two-step process.
Now there is also the command CD, period, it won't do anything.
It is a valid command.
The single dot means the current working sub-directorie, which is where you already are.
So you're not really changing directories at all.
Now, deltree, this was added later as an external command, and what an external command that
means it exists as a file on your disk, separate from the others.
That means if you want to create a boot disk and have this available to you, you have
to make sure it's copied onto the boot disk.
It won't happen when you just do the usual formatting stuff.
Now it'll delete an entire sub-directorie tree.
In other words, a sub-directorie, all of the files it contains, all of the sub-directories
it contains, all of the files, they contain, et cetera, all in one easy command, which makes
it a very dangerous command, because it can wipe out so much stuff so easily.
It even ignores file attributes, so you can wipe out hidden, read-only, and system files
without knowing it.
You can even wipe out multiple trees by specifying them in the command.
So for instance, I could do a command like at the c-pront, deltree, space, c-colon
backslash letters, space, c-colon backslash memos.
This would wipe out both of these sub-directories in one command.
So it's really one of those commands where you ought to think twice before you use it.
It has its place, definitely.
I can remember how tedious it was to first go into each sub-directorie, delete the individual
files, check each sub-directorie for contents, delete each sub-directorie one at a time,
then jump up a level and repeat the process.
So deltree is a great time saver when you need it, but I would never use it for ordinary
maintenance because one false move can do so much damage.
Now, of course, we have to talk about the DIR command itself.
Now, DIR is to display the contents of the sub-directorie, but it can also function like
a search command, which we would get to.
So this is one of the most used commands in all of DOS, and learning how to use it properly
is a great time saver.
DIR will display the contents of the current working sub-directorie, or with an optional
path argument, and will display the contents of some other sub-directorie.
Now, the real power of the DIR command comes with optional switches that are available
to you, and then later on we're going to look at some other things you can do.
So one of the switches, slash P. Now this is a forward slash.
In DOS, backslashes are used for directory structures.
Forward slashes are used for switches, so it's just one of those things you have to get
used to here.
So forward slash P will pause the screen when a full screen's worth of information has
been displayed, and then you will see, press any key to continue, and the press of the
key will display one more screen.
So this is great for searching long lists, and you can have, remember, you can have up
to like 500, something like 512, I think, in a directory.
Now then, forward slash W will display the file names and sub-directorie names in several
columns, so the slash W means wide.
Now it's just the names, it's not going to give you any of the other details.
Now if you want to just have a normal listing, but without all of the other file attributes
and information, you can do forward slash B for bear, the bear format displays file names
only without any other information.
So I think that's enough for this.
This is Huka for Hacker Public Radio, signing off, and is always encouraging you to support
free software.
Bye-bye.
You've been listening to Hacker Public Radio at HackerPublicRadio.org.
We are a community podcast network that releases shows every weekday Monday through Friday.
Today's show, like all our shows, was contributed by an HBR listener like yourself.
If you ever thought of recording a podcast, then click on our contributing to find out
how easy it really is.
Hacker Public Radio was founded by the digital dog pound and the infonomicum computer club,
and is part of the binary revolution at binrev.com.
If you have comments on today's show, please email the host directly, leave a comment on
the website or record a follow-up episode yourself.
Unless otherwise stated, today's show is released on the creative comments, attribution,
share a light, free.or license.
