Quote: Originally Posted by donnyb
This seems so simple, but I don't see how to do it. I want to have a list of all files on my C: drive or maybe on my D: drive, etc. In the old days it was DIR *.*
I am using Win 7 - 64.
Try this (all commands in quotes should be typed without the quotes):
- Press <WINDOWS_KEY>+<R> to open the Run box
- type "CMD", and press <ENTER> to launch the command line utility
- Type "D:" and press <ENTER> to go to that drive (Change D to whatever drive letter you need - provided that the drive exists, of course)
- type "CD\" and press <ENTER> to go to the root folder of the drive
- Now, here is where this get interesting. Use one of the following:
To get a file listing that include such things as file dates, sizes, etc, type the following command, followed by <ENTER>
This could take awhile, so be patient. If all you want is a raw list of files, then use the following command, which shows all files with fully-qualified pathnames in the list:
If you want to have the listing sorted, just add "/ogen" to either of the above commands ("/o" tells dirs to sort the list, "g" puts folders at the top, "e" sorts by extension, "n" by name - in that order). For example:
If you want to include hidden files/folders, just add "/a". For example:
If you only want to see folders, then add "/d" to the command (really usefull only if you are using "/b" also:
It is also possible to redirect the output to file or the clipboard, regardless of which of the above forms of DIR you use:
- "DIR *.* /s /b >LIST.TXT" will create a text file named LIST.TXT in the current folder, and will contain the desired output of the DIR command. You can specify you own filename if you like, just remember to enclose the filename in quotes if it contains spaces, For example "DIR *.* >"Files List.txt""
- "DIR *.* /s /b | CLIP" will send the output of the DIR command to the windows clipboard.
If you want more information on DIR, use the following command to display all available command-line switches:
This may sound extremely odd, but I use the DIR command alot when I need a list of files that I can paste into Excel when I want to do a once-off processing of the files to maybe cretae a batch file to rename or copy them, and the task at hand does not warrant the creation of a program in Delphi.