super useful dos commands
Useful DOS commands to automate stuff
Generating a list of files in a folder
Useful little DOS command for Windows which generates a list of the files in a folder.
1
Navigate to the folder in question using Windows Explorer.
2
Copy the folder path.
3
Open up an Administrator command prompt.
4
Type CD " and then right click your mouse to paste the path from the clipboard. Type " and press ENTER. Make sure you have surrounded the path with quotation marks in case it has any spaces in it.
5
Run the following DOS command...
dir /B /ON > list.txt
...replacing the filename if necessary.
Create empty files from a list
Great if you want to create a batch of empty 'placeholder' files.
1
Create a list of filenames using Excel, Google Sheets.
2
Copy the list into a text file using Notepad.
3
Save the file as list.txt in the folder where you would like the files creating.
4
Open up an Administrator command prompt.
5
Navigate the the same folder using the CD command.
6
Run the following DOS command...
for /f "delims=" %F in (list.txt) do copy nul "%F"
... replacing the filename in brackets with the filename you used if it was different.
Files to Folders
I find this useful for moving PDFs into folders to keep things organised.
@echo off
setlocal enabledelayedexpansion
echo Starting File Organization...
echo.
for %%F in (*.*) do (
if "%%F" neq "%~nx0" if "%%F" neq "]" (
echo -----------------------------------------
echo Processing File: "%%F"
if exist "%%~nF" (
echo [i] Folder "%%~nF" already exists.
) else (
echo [+] Creating folder "%%~nF"...
md "%%~nF"
)
echo [^>] Moving "%%F" into folder...
move "%%F" "%%~nF" >nul
)
)
echo.
echo -----------------------------------------
echo All operations complete.
pause
1
Open Notepad.
2
Copy and paste the code above into it.
3
Go to File > Save As.
4
Name the file organize.bat.
5
Important: In the "Save as type" dropdown, select All Files (otherwise it saves as a text file).
6
Move organize.bat into the folder where your files are.
7
Double-click organize.bat to run it.
Last modified: December 16th, 2025
