Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: DELETE batch using list.txt

15 Aug 2015   #1

Windows 7 Ultimate x64
DELETE batch using list.txt

Hey All, I just joined this forum to find some help on a specific topic that I've been researching for like two hours now on google. I have a list of 1000 files that I need to delete from location.

Thanks in advance

My System SpecsSystem Spec
15 Aug 2015   #2

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

Hi and welcome to SF.

Here's your batch file. It assumes your List.txt is newline separated.

:: th-378655.bat [TxtFileList]
@echo off
REM Delete files/folders specified in a newline delimited txt file list. 
set "default_list_path=C:\Users\%USERNAME%\Desktop\ListOfFilesToDelete.txt"
if not "%~2"=="" echo Error: unexpected arguments& exit /b
if not "%~1"=="" ( set "list=%1" ) else (
    set "list=%DEFAULT_LIST_PATH%"
if not exist "%LIST:"=%" echo Error: list could not be found& exit /b
set /a delete_counter=0
for /f "delims=" %%I in ('type "%LIST:"=%"') do (
    if exist "%%~fI" (
        set /a delete_counter+=1
        if exist "%%~fI"\* (
            rd /s /q "%%~fI"
        ) else (
            del /q "%%~fI"
    ) else (
        echo No such path "%%~I".
echo.& echo %DELETE_COUNTER% files or folders were deleted.
My System SpecsSystem Spec
16 Aug 2015   #3

Windows 7 Ultimate x64
thanks Pyprohly

thank you very much Pyprohly, one more favor can i have a same batch file for MOVE command (cut)
My System SpecsSystem Spec


 DELETE batch using list.txt

Thread Tools

Similar help and support threads
Thread Forum
How to delete registry key or value in Batch list.
i did every step about to take ownership and giving permission on my user to able edition but cmd command bat does not work. please help to do correctly every step to follow. REG delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based...
Windows Updates & Activation
Help batch file to move files in list to created subdirectory
Please excuse me in advance because I am not very experienced making batch files. I'm not asking for a free lunch and would gladly paypal someone some cash for a working batch file. I have a parent folder that contains several subfolders. Each subfolder has several files in them. I need a batch...
General Discussion
Batch File to Move a list of files.
Hey All, I just joined this forum to find some help on a specific topic that I've been researching for like two hours now on google. I have a list of 1300 files that I need to move from one location to another (move not copy). I've found this batch file created by Neutron16 which performs a Move...
General Discussion
Batch File - List files modified within last 7 days
Hi All, I'm trying to create a batch file that will create a text file listing all the files within a folder that has been modified within the last 7 days, i thought this was going to be easy using some kind of switch that looks at the modified date but that doesn't seem to exist and i can't...
General Discussion
How do I write batch file to delete thousands of files
Was infected by the matsnu1 virus recently which encrypes and locks all your data files. Got all my files back by running matsnu1decryp.exe You need an original clean file before the virus struck for it to work out how to decrypt all your other files does does save the day. Down side is that you...

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:07.
Twitter Facebook Google+