Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

Where is dir in windows?

5 Answer(s) Available
Answer # 1 #

Description of the command :

Output :

Usage of the command : The command is mainly used for displaying the list of files and subdirectories in a directory. This could be done by executing the Dir command without any arguments.

which would produce an output similar to this. Output :

This would serve the purpose for most users, but the command offers more functionality than this, By appending various switches we could modify the working of the command, to produce custom output. We would be looking over at some of the commonly used switches of the command. Displaying files/subdirectories having certain attributes : You can filter the output of dir by sending/A switch, followed by a specific attribute. What this will do is it will display only those files/folders which do have the provided attributes. The command would have the following syntax as follows.

Where attribute will be a one/combination of one of the characters from the following list

According to the above list, If you want to display a list of Directories only. You can use the given below command.

Which will display a list of subdirectories (Junction Points & Directory Symlinks as well) within the current directory. Displaying file/subdirectories of a directory using its absolute/relative path : You can get the list of file/subdirectories of now only the current directory, but other directories as well. If you provide the full path to the directory you can execute the dir command on that directory. The syntax would be as follows :

Where Path to the Directory is either Relative or a full path to the Directory that we are interested in. For getting the contents of “C:\Users\Public” directory, the command would be :

It should be noted, that if the path to a file is provided as an argument, then only information regarding that file would be displayed. Sorting the output of Dir command : You can sort the list of files/folders in the output of dir command using the /O switch. The switch takes one/combination of these characters to produce a sorted output.

According to the above list, if you want the output to be sorted by the size of files (in descending order). The command syntax would be as follows.

Which would produce an output where the files having larger size would be at the top of the list, and smaller files/folder at the bottom. Note – In general, Directories would be at the bottom, as they aren’t as generally fixed size (existing as file table entry), as opposed to a file. Displaying output of Dir command in minimal format : The output of the dir command contains way too much information than what one may be interested in. In order to display the output of Dir command, in a bare format we can append /B switch to it. This will remove additional information such as Time of modification, Sizes, Types, etc. from the list of entries. The command syntax would be as follows.

Example – Consider if a directory has the following content. Then running the Dir command on the directory would produce the following output.

While running the Dir command with /B switch would produce

Which is easier to read for most users. Note –

[5]
Edit
Query
Report
C.J. Badola
KILN FURNITURE CASTER
Answer # 2 #

The dir command is available from within the Command Prompt in all Windows operating systems including Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP.

[4]
Edit
Query
Report
Bijay De
DESK CLERK BOWLING FLOOR
Answer # 3 #

The DIR command is a powerful Windows Command Prompt function that lists all files and subdirectories contained in a specific directory. The DIR command also offers some switches that unlock some powerful functionality. Let’s take a look.

You can use the DIR command by itself (just type “dir” at the Command Prompt) to list the files and folders in the current directory. To extend that functionality, you need to use the various switches, or options, associated with the command.

You can add “/A” followed by a letter code after the DIR command to display files with a specific attribute. These letter codes include:

So, for example, to display just the directories in the current path, you’d type the following command and then hit Enter:

You can combine those codes, too. For example, if you wanted to show only system files that are also hidden, you could use the following command:

You also can add a “-” (minus) in front of any of those letter codes to specify that the DIR command does not show that kind of file. So, for example, if you don’t want to see any directories in the results, you could use this command:

One more tip: Instead of cramming the main switch and the letter code together the way we did in our examples, you can use a colon to separate the switch from its optional codes. Like this:

It can make things a little easier to parse, but it’s entirely optional.

Using the /b switch with the DIR command strips away all excess information, displaying only the name of the folders and files in the current directory and not attributes like file size and time stamps. Type the following command to make it work:

In modern versions of Windows, the Command Prompt shows large numbers separated by commas (so: 25,000 instead of 25000). This wasn’t always the case. In older versions, you had to use the /c switch to show those commas.

Why bother including it here if it’s already the default? Because if for whatever reason you don’t want to show those commas, you can use this switch along with the “-” minus sign:

You can use the /D switch to display results in two columns instead of one. When you display results this way, the Command Prompt does not show extra file information (file size and so on)—just the names of the files and directories.

The /L switch displays all names of files and folders as lowercase.

By default, the Command Prompt displays the names of files to the far right. The /N switch used to be used to achieve this effect. Now, you can use it along with a “-” (minus) to have filenames displayed on the far left instead.

You can use the /O switch followed by a letter code to display directory results sorted in various ways. Those letter codes include:

So, for example, you could use the following command to sort results by time and date, with older entries appearing first:

You can also add “-” (minus) before any of the above options to reverse the order. So, for example, if you want to sort files by time and date with newer entries appearing first, you could use this command:

Some directories have hundreds or thousands of files. You can use the /P switch to have the Command Prompt pause the results after it displays each screen. You have to press a key to continue viewing the next page of results.

Using the /Q switch on the DIR command displays metadata tied to files and directories, along with ownership details.

The /R switch displays any alternate data streams (ADS) that files might contain. ADS are a feature of the NTFS file system that let files contain additional metadata for locating files by author and title.

You can use the /S switch to recursively show all files and folders inside the current directory. This means all files and folders in every subdirectory, all files and folders in those subdirectories, and so on. Be prepared for a lot of results.

Using the /T switch along with a letter code lets you sort results by the different time stamps associated with files and folders. These letter codes include:

So, for example, to sort results by the time items were created, you could use the following command:

The /W switch is similar to /D (which shows columns), but instead, it sorts the results in wide format horizontally.

The /X switch shows a file’s short name when the long name doesn’t comply with 8.3 naming rules.

Using the /? switch displays helpful information regarding the DIR command, including a brief description of all the switches we’ve talked about.

All right, now you know about the switches and options associated with the DIR command. Let’s take a look at a few real-world examples to gain a better understanding as to how you can start putting them to use.

A simple dir command returns a list of all files and folders in the current directory you’re in.

Running the following command shows all system files inside your current path by utilizing the “s” attribute:

But what if you want to view all files of a certain type within all subsequent folders of your current path. That’s easy, just run this extremely fast and useful command:

You can replace the “.mp3” part with whatever file format you’re looking for.

The asterisk acts as a wildcard, saying “find anything with .mp3 file format at the end” while the “/s” recursively looks through all folders within your current path.

RELATED: This Command Prompt Trick Searches Way Faster Than Windows Explorer

Now, you may have noticed that returned a LOT of results. Almost too many to be able to read before they scrolled off the screen. This is where we can use the pause switch to give you a chance to read them. To do that, modify the command like this:

Another trick the Command Prompt offers is called piping. You can use the “>” character to send the results of one command to another place or service. A good example of this is sending all your results to a text file. You can then scroll through them later or import them into other types of documents. To do that, you could use the command:

RELATED: How to Print or Save a Directory Listing to a File in Windows

We added the /b switch in there to only output the filenames themselves, without any of the other details. The greater than symbol reroutes everything normally displayed in your results directly to the file.

There are many more combinations and uses for the DIR command, but this should be a good starting point to help you understand the basics.

[2]
Edit
Query
Report
kvvtkza Aqil
MEXICAN FOOD MAKER HAND
Answer # 4 #

Displays a list of a directory's files and subdirectories. If used without parameters, this command displays the disk's volume label and serial number, followed by a list of directories and files on the disk (including their names and the date and time each was last modified). For files, this command displays the name extension and the size in bytes. This command also displays the total number of files and directories listed, their cumulative size, and the free space (in bytes) remaining on the disk.

The dir command can also run from the Windows Recovery Console, using different parameters. For more information, see Windows Recovery Environment (WinRE).

To display all directories one after the other, in alphabetical order, in wide format, and pausing after each screen, make sure that the root directory is the current directory, and then type:

The output lists the root directory, the subdirectories, and the files in the root directory, including extensions. This command also lists the subdirectory names and the file names in each subdirectory in the tree.

To alter the preceding example so that dir displays the file names and extensions, but omits the directory names, type:

To print a directory listing, type:

When you specify prn, the directory list is sent to the printer that is attached to the LPT1 port. If your printer is attached to a different port, you must replace prn with the name of the correct port.

You can also redirect output of the dir command to a file by replacing prn with a file name. You can also type a path. For example, to direct dir output to the file dir.doc in the Records directory, type:

If dir.doc does not exist, dir creates it, unless the Records directory does not exist. In that case, the following message appears:

To display a list of all the file names with the .txt extension in all directories on drive C, type:

[2]
Edit
Query
Report
Tippy Fabre
Scenic Artist
Answer # 5 #

DIR command is a Command Prompt command. You can type this command in Windows Command Prompt to display information about all files and subfolders in the current directory. It shows the file name, size, last modification date and time of each file.

DIR command is available in Command Prompt of all Windows systems incl. Windows 10/8/7/Vista/XP. Older versions of Windows also have the DIR command but have fewer options. The DIR command is also included in all versions of MS-DOS.

You can type DIR command itself to display the files and folders in the current directory. If you want to extend DIR command functions, you can use various switches and options related to this command to conduct different operations to files/folders. The DIR command can be executed alone.

DIR /A

The most commonly used DIR command line is /A. You can add a specific file attribute after /A to only display files with the specific file attribute. The file attributes are represented with a series of letters and each of them stands for a different file attribute, you can check then below.

You can add a specific file attribute after /A to display certain files. You can check the examples below.

dir: list all files and directories in the current directory.

dir *.exe: list all files with the file extension .exe.

dir *.exe *.doc: list all files with the file extension .exe and .doc.

dir /ad: list all directories in the current path.

dir /ash: show hidden system files.

dir /a-d: list all files but no directories.

dir /a:r-a: display all read-only non-achieve files.

DIR /B

You can type this DIR command to only display the directory name, file name and extension in the current directory.

DIR /O

You can use this command to display results in a sorted order. You can add a letter code below after the /O switch to sort the displayed result.

Tip: You can add a minus – to any of the above letter code to reverse the display order, e.g. dir /o–d, this will sort the display result by time and date, and the newest file displays first.

[0]
Edit
Query
Report
Tonny Madhi
GEAR SORTING AND INSPECTING MACHINE OPERATOR