5.2. Managing Directories

All files that are saved to disk are stored in a hierarchical directory structure. All the files could be placed at the top of this structure, but it would be disorganized, and therefore poorly managed. Also, most top-level directories, or root directories, can hold a limited number of files. This directory structure can hold as many nested subdirectories as you want. The commands discussed in the following sections allow you to get listings of files as well as create and delete directories on your disk.


All command line tools in this section have not changed substantially since MS-DOS.

5.2.1. dir

The first command that you will see is the directory command (dir). This command is used to get a listing of the files that are in a directory on your disk. Using dir by itself gives you the listing of your current directory. The current directory is usually listed in the command prompt, like this:


The dir command is very useful and has several options discussed later in this section. First, though, you need a firm grasp of wildcards, relative paths, and absolute paths. Wildcards

Two wildcards can be used to modify what results you receive: * and ?. These can be used multiple times in different combinations in the same command to filter the results.

The * wildcard represents one or more characters. Here is an example of using the * wildcard to retrieve a list of files that match a certain pattern. The command

dir WIN*.*XE

returns ...

Get CompTIA A+® Certification All-In-One For Dummies®, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.