Sorting Listings
By default, dir sorts files by name.You can list files in some other order by using the /o option, followed by one or more letters indicating which parts of the file information to use for sorting. Reference List previous, earlier in this tutorial, shows the whole list of sort options. Some of the most useful combinations are listed here:
Option Sorts /o-s By size. Largest first /odn By date. Oldest first, then by name /o-dn By date. Newest first, then by name /oen By type (extension), then by name
Listing Hidden Files
Normally, hidden files are omitted from dir listings. (What would be the point otherwise?) However, you can ask dir to list hidden files by adding /ah to the command line.The /a flag instructs dir to list files with specified attributes, and the h indicates that you want to see hidden files.
You can use the /a option to select files based on the other attributes listed in Reference List previous. For example, /as lists only system files, /a-s lists only files that are not marked as system files, and so on.
In this tutorial:
- The CMD Command-Line
- CMD Versus COMMAND
- Running CMD
- Opening a Command Prompt Window with Administrator Privileges
- CMD Options
- Disabling Command Extensions
- Command-Line Processing
- Console Program Input and Output
- Using the Console Window
- I/O Redirection and Pipes
- Copy and Paste in Command Prompt Windows
- Command Editing and the History List
- Name Completion
- Enabling Directory Name Completion
- Multiple Commands on One Line
- Grouping Commands with Parentheses
- Arguments, Commas, and Quotes
- Escaping Special Characters
- Configuring the CMD Program
- The Search Path
- Changing the Path
- Predefined and Virtual Environment Variables
- Setting Default Environment Variables
- Built-in Commands
- Extended Commands
- Listing Files with the Dir Command
- Paginating Long Listings
- Printing Directory Listings
- Sorting Listings
- Locating Alternate File Streams
- Setting Variables with the Set Command
- Conditional Processing with the if Command
- Scanning for Files with the for Command
- Using the for Command's Variable
- Processing Directories
- Numerical for Loop
- Getting More Information