Windows operating system provides command line tool named MS-DOS. This command line have different tools and capabilities for daily operations. We will look some simple steps about usage like navigation, list files and directories etc. We will mainly use
dir command for this tutorial.
Help information about
dir command can be listed like below.
$ dir /?
Windows operating systems generally uses drive names for different partitions or disks. Most common usage of drive is splitting disk into two part and setting their name as
D: . If we have a CD-ROM we will also have a drive named
E: . Changin the command prompt path between these drives can be done by issuing drive names into command line.
In this example we will change drive to
D: with the same command.
Or change drive to C: back again with command
Navigate Upper Directory
Windows file system NTFS uses hierarchical structure for storing directories and files. In order to access upper directories and files we need to change the command line path with
cd .. command to the upper directory.
$ cd ..
Navigate Selected Directory
Another mostly used navigation is changing command prompt directory into a child directory. We will use
cd command with the directory name where we want to navigate. In this example we will navigate into directory named
$ cd Users
List Files and Folders
Current working directory files, folders and folders can be listed with the
dir command. We will do not provide any parameter.
This command listed all files and directories with their date time and type information.
List Only Directories
In previous command we have listed all files, folders and directories but how can we only list directories. We will provide directory attribute with
$ dir /A:D
List Only Files
Another use case for dir command is listing only files. We will list only files with
/A:-D option like below. This option actually negates so this will list non directories which is equal to files.
$ dir /A:-D
List Only Hidden Files
Hidden files are designed to be used by operating system. Users do not need these files to navigate, operate. This files generally holds cache or temporary values. We will use
/A:H for list hidden files.
$ dir /A:H
The hidden files listing output provides information like date time and files type like
Sort By Name While Listing
Sorting is very useful feature while looking specific directories and files. Files, folders and directories can be sorted with
/O:N option like below.
$ dir /O:N
Sort By Name While Listing In Reverse Order
We can list files, folders and directories alphabetically in reverse order. This start from
z to sort. We will use
$ dir /O:-N
Sort By Size While Listing From Smallest To Bigger
Files can be listed according to their sizes with the
/O:S . This will start from smallest file and continue to bigger file.
$ dir /O:S
Sort By Size While Listing From Bigger To Smallest
We can reverse the default sorting according to size. We will sort from bigger to the smallest with the
$ dir /O:-S
Sort By Date By Listing
Files, folders and directories can be listed according to their creation date with the
$ dir /O:D
Display Owner Of The File
File, folders and directory owners can be listed and printed to the command line with
$ dir /Q
In the output we will see the user and user domain or local system information.
How can we list files, folders and folders deeper than current directory. We want to list all child file and folders and theirs childs up to end too. This is called recursive listing. We will use
/S option to list all files and folder recursively.
$ dir /S
Display Creation Time
Creation time of the files, folder and directories can be listed with the
/T:C option like below.
$ dir /T:C
Display Last Access Time
Last access time to the files, folder and directories can be
$ dir /T:A
Display Last Written Time
Las written time shows what is the last change time of the file or directory. We will use
$ dir /T:W