Windows Operating Systems maintains attributes for the files to manage them in the File System. There are different file attributes; read-only files, System files, Archived files etc,.
DIR
command provides the opportunity to the Users to display the files with specified attributes, through the switch “/A”. For example, below command displays the list of files and folders including hidden files also from the current directory.
C:\> dir /a
Yes. By default, DIR command won’t shows the hidden files; the hidden files will be visible through “/a” switch.
We can pass different attributes through the switch “/a” to display files with specified attributes. Here are the values or attributes we can pass along with this switch.
D – This attribute represents the directory.
R – Represents the read-only files
H – It is for hidden files
A – Represents the files ready for archiving
S – For System files
Let’s use these attributes to display the files and directories.
Display the Directories ONLY
By default, DIR command displays both files and folders from the specified or current directory. By using “D” attribute we can change this to display ONLY the directories. Remember that, attributes should be passed through the switch “/a”.
Below is the command to display ONLY the directories.
C:\> dir /ad
Observe the results that, there won’t be any files listed in the results. All entries are directories ONLY.
Display the Hidden files ONLY
We use “H” attribute to display the hidden files. At the beginning of this Article, we have seen displaying hidden files using the switch “/a”. Then what is this attribute about? By using “/a” switch it displays both hidden and non-hidden files. To display ONLY the hidden files we use “H” attribute. The command looks like below.
C:\> dir /ah
The above command displays ONLY the hidden files.
Display System files
System files are for specific purpose. The attribute “S” represents the System files. These files have to be treated cautiously; and deleting them may cause System failure.
Below is the command to display the System files.
C:\> dir /as
Display the files which are ready for Archiving
When archiving attribute “A” is set for the files, the System recognizes that the files are ready for Archiving; means, ready for back up. Below command shows the list of files which are ready for Archiving.
C:\> dir /aa
Be on learning path always!
// Malin