All of us know that we can use various commands of Command Prompt and PowerShell to view the files of any specific directory. What if we want to preserve this listing for our own reference or for printing purposes? Well, we can simply do this using Windows 10. In this article, we will explain to you the method through which you can print or save a directory listing to a file in Windows 10.
Saving a Directory Listing in a File in Windows 10
In order to print or save a directory listing to a file in Windows 10, you will need to perform the following steps:
Type power shell in the search section of your taskbar and click on the search result to launch the power shell window. The newly opened PowerShell window is shown in the following image:
If you want to see the directory listing of a directory other than the current one, then you can navigate to your desired directory by using the cd command. Otherwise, if you want to save the directory listing of the current directory, then simply type the command,
dir > directorylisting.txt
in your PowerShell window and then press the enter key. You can use any file name of your choice for saving your directory listing instead of using directorylisting.txt. This command is also highlighted in the image shown below:
As soon as you will press the enter key, your command will be executed as shown in the following image:
You will notice now that a new file named directorylisting.txt will be created in the same folder path as highlighted in the image shown below:
Just double click on your newly created text file in order to launch it and you will be able to see all the files within your desired directory as shown in the following image:
By following the method discussed in this article, you can easily save a directory listing using the PowerShell in Windows 10. You can even print this directory-listing file in the future if you want.