dir command to save a folder’s file names to a plain-text file, then open that file in Notepad and print it. The procedure below prints the list, not the contents of the files. It covers a single folder first, with an option for including subfolders.
Before you create the list
You need access to the folder you want to list and permission to read it. To print on paper, you also need an installed, available printer. No administrator account or restart is normally required.
The main command produces one file name per line, sorted by name. It includes hidden and system files, but it does not include folder names or search inside subfolders. You can change those choices using the alternatives below.
The examples save the list in your account’s temporary folder as FolderFileList.txt. That keeps it separate from most folders you might be listing. Because temporary files can be cleaned up, use Notepad’s File > Save As to keep a permanent copy elsewhere.
Important: The > character in the commands creates the output file or replaces its existing contents without asking. Before running a command, check whether a file named FolderFileList.txt already exists in the destination. If it does and you need it, use a different output name.
To check the temporary folder, press Windows + R, enter %TEMP%, and press Enter. Look for FolderFileList.txt. You can leave this File Explorer window open.
Create the file list
- Find the folder’s full path. Open File Explorer and navigate to the folder whose files you want to list. Click the address bar to display the path, then copy it.
For example, a path might look like:
C:\Users\Taylor\Documents\Project Files
Use your own path rather than this example. If the address begins with\\, it is a network path; use the network-folder instructions later in this guide instead of step 3. - Open Command Prompt. Press Windows + R, type
cmd, and press Enter.
Use Command Prompt for the commands in this guide. A PowerShell window can interpretdirand output redirection differently. - Change to the folder. Type
cd /d, followed by a space and the copied path in double quotation marks. For example:
cd /d "C:\Users\Taylor\Documents\Project Files"
Press Enter. The/dswitch also changes the current drive if necessary.
Check the prompt before continuing: it should now show the folder you selected. You can also typecdand press Enter to display the current directory. If Windows reports that it cannot find the path, do not continue until you have corrected it. - Check what will be listed. Run:
dir /b /a:-d /o:n
You should see file names in the Command Prompt window. The command does not open or change the files./buses a bare format: names without the usual heading, dates, sizes, or totals./a:-dselects non-directory entries. Because an attribute filter is specified, hidden and system files can appear./o:nsorts by name.
- Save the list. After checking that the destination name is safe to use, run:
dir /b /a:-d /o:n > "%TEMP%\FolderFileList.txt"
Press Enter and wait for the prompt to return. The names go to the text file rather than appearing in the window. Error messages can still appear in Command Prompt, so read any message before proceeding.
If%TEMP%is the folder you are listing, or is inside a tree you later list recursively, choose a different existing output folder outside the folder or tree being listed. Otherwise, the output file can appear in its own list. - Open the result in Notepad. Run:
notepad "%TEMP%\FolderFileList.txt"
Notepad should open the saved list. If you chose a different destination or file name, use that same path here.
If Notepad says the file does not exist or asks to create it, cancel and return to Command Prompt. Check the output path and any error from step 5 rather than creating an empty file.
Review and print the list in Notepad
Compare several names in Notepad with the folder in File Explorer. Remember that the list is a snapshot: files added, removed, or renamed after you ran dir will not automatically update it.
If you want to keep the list, select File > Save As, choose a permanent folder and file name, and save it. This saves the text listing, not copies of the listed files. Be careful not to select an existing file you want to keep as the Save As destination.
To print:
- In Notepad, select File > Print or press Ctrl + P.
- Select the intended printer. Check the available page range and print settings.
- Select Print.
If you prefer a PDF rather than paper, select Microsoft Print to PDF if it is available, then choose where to save the PDF when prompted. Select the physical printer instead if you want paper.
For a long list, check the page range before printing. Notepad’s File > Page Setup also lets you adjust the header and footer. For example, leave those fields empty if you do not want a document title or page number on the printout.
Choose a different kind of list
Run these commands from the same Command Prompt window after confirming that the current directory is still the folder you want. Each example writes to the same temporary file, so each will replace its previous contents. Change the destination name if you want to keep more than one version.
Include files in subfolders
Use /s to search the current folder and its subfolders:
dir /b /a:-d /o:n /s > "%TEMP%\FolderFileList.txt"
With /b and /s, the list contains paths, rather than just the names in the top-level folder. This makes it possible to distinguish files with the same name in different subfolders. A large folder tree can produce a long list and take longer to scan.
Save the output outside the entire tree being listed. Check the Command Prompt for errors, particularly if you do not have access to every subfolder. A completed command does not by itself prove that every protected location was readable.
Exclude hidden and system files
If you want non-directory entries without hidden or system attributes, use:
dir /b /a:-d-h-s /o:n > "%TEMP%\FolderFileList.txt"
The -h and -s parts exclude hidden and system entries. Add /s before the > if you also want to search subfolders.
Include folder names as well as file names
If your printout should show the immediate subfolders alongside files, remove the non-directory filter:
dir /b /a /o:n > "%TEMP%\FolderFileList.txt"
This includes hidden and system entries. In bare format, the output does not label a line as a file or folder, so compare it with File Explorer if that distinction matters.
Include dates and sizes
For a more detailed listing of files in the current folder, omit /b:
dir /a:-d /o:n > "%TEMP%\FolderFileList.txt"
This format includes directory information, last-modified dates and times, file sizes, and totals. It uses more horizontal space than the bare list, so review the print settings before printing.
List a network folder
Command Prompt cannot use a network path in the same way as an ordinary drive path with cd /d. For a folder whose path starts with \\, use pushd instead.
- In Command Prompt, enter the network path in quotes, replacing the example with your actual server, share, and folder:
pushd "\\ServerName\ShareName\FolderName" - Check for an error and confirm that the prompt changed. With normal Command Prompt settings,
pushdtemporarily assigns an available drive letter to the network location. - Run the same listing command:
dir /b /a:-d /o:n > "%TEMP%\FolderFileList.txt" - Open the file in Notepad using the earlier command. When you are finished with the network location, return to Command Prompt and run:
popd
This returns to the previous directory and removes the temporary drive assignment created bypushd.
If pushd fails, confirm that you can open the share in File Explorer and that you have permission to access it. Do not print a previously created list as though it were a fresh result.
Troubleshoot the result
- The list is empty or Command Prompt says “File Not Found.” Confirm the current folder with
cd, then run the listing command without> "%TEMP%\FolderFileList.txt"to see what it returns. There may be no files matching the selected attributes. An empty output file can still have been created, so its presence alone is not proof of a successful listing. - The wrong folder appears in the list. A failed
cdleaves you in the previous directory. Repeat thecd /dcommand with the correct quoted path, check the prompt, and regenerate the list. Use a new destination name if you need to preserve the earlier output. - A file is missing. Check whether it is in a subfolder; the primary command only lists the current folder. Also check whether you used the variant that excludes hidden and system files. For a recursive list, check the Command Prompt for access errors.
- The list contains an unexpected
.txtfile. The output file may be inside the folder or tree being listed. Save the output to an existing location outside that folder or tree, then run the command again. - A name displays with incorrect characters. Command Prompt output and Notepad may not interpret character encoding the same way. Do not assume the printout preserves every name correctly: compare it with File Explorer before using it as a record. If accuracy for accented or non-Latin names is essential and the mismatch persists, use a Unicode-capable inventory method rather than printing an unverified list.
- Nothing prints. Make sure you selected the intended printer rather than a PDF or print-to-file option. To test the printer separately, open its properties:
- Windows 11: Start > Settings > Bluetooth & devices > Printers & scanners. Select the printer, then Printer properties.
- Windows 10: Start > Settings > Devices > Printers & scanners. Select the printer, then Manage > Printer properties.
If you no longer need the temporary text file, close it in Notepad, open %TEMP% in File Explorer, and delete only FolderFileList.txt after confirming it is the list you created. This does not delete the files named inside it.