How to delete files from a folder using a list of file names in windows?
Type this on the command line, substituting your file for files_to_delete.txt
:
for /f %i in (files_to_delete.txt) do del %i
A version of this suitable to include in .cmd
files (double %%) and able to deal with spaces in file names:
for /f "delims=" %%f in (files_to_delete.txt) do del "%%f"
Using PowerShell:
Get-Content c:\path\to\list.txt | Remove-Item
Simple way is copy the txt file to a file called mydel.bat
in the directory of the files to delete. Using an editor like Microsoft Word edit this file. Do a global replace on Newline normally ^p
in Word. Replace it with space/f^pdelspace
. This will change
File1.bin
File20.bin
File21.bin
to (with /f
for "force delete read-only files"):
File1.bin /f
del File20.bin /f
del File21.bin /f
del
Edit the fist line to add the del
space
and delete the last line.
Run the batch command.