Click Start > type cmd and press Enter.
The dos command prompt opens. In my case, it always opens with the default directory path
C:\Users\mybook99>
So type cd.. and press Enter, it will move you one level up.
C:\Users\mybook99>cd.. [enter]
C:\Users\>cd.. [enter]
C:\>
Now if you type dir and press Enter, you will get the list of folders and files under C drive
C:\>dir [enter]
Change the default drive
By the way, I want to change my drive from C to E. So type E: and press Enter
C:\>E: [enter]
E:\>
I could do it at the beginning as well, but I wanted to show you few other steps like going up one level in the directory path at a time.
C:\Users\mybook99>E: [enter]
E:\>
![Image](http://shamskm.com/forum/exceltutor/excel2/list_files_in_dos_command_prompt.jpg)
Now navigate to your folder
Now let me navigate to my folder
E:\>dir [enter]
I get list of all folders and files in E drive but I want to go to my specific folder called ExcelTest
E:\> cd ExcelTest [enter]
E:\ExcelTest>
To list the files and folders contained in ExcelTest enter
E:\ExcelTest>dir [enter]
To list the files in the main folder as well as in all the subfolders enter
E:\ExcelTest>dir/s [enter]
Save the list either as .csv or .txt file
Now, first I will save all the files and folders in ExcelTest as .csv (comma separated values file) and .txt (text) file
E:\ExcelTest>dir>mytest.csv
E:\ExcelTest>dir>mytest.txt
Now you will find both the mytest.csv and mytest.txt files in the ExcelTest directory. Click them to open – csv files open in Excel and txt files open in text editors.
But if you want to save all the files in the subfolder together with the main folder then enter
E:\ExcelTest>dir/s>mytest2.csv
E:\ExcelTest>dir/s>mytest2.txt
The files are now saved in your ExcelTest directory. Click them to open.
Clean the command prompt
By the way, your command prompt is now full of lists from directories, folders and files: - and now you want to clear all these contents, so enter
E:\ExcelTest>cls [enter]
It will clear all the contents from the dos command prompt. cls stands for clear screen.
Close the command prompt
To close the command prompt type exit and press Enter
E:\ExcelTest>exit [enter]