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
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
Window Batch file to delete folders/subfolders that contain files
I have a root folder called "Names"..It has subfolders ,these subfolders contains files. I will be giving the names of subfolders to be deleted in text file Ex.. John Tom Rambo. I will be reading the folder names from text file & delete only those folders with files inside the folder also ....
General Discussion
How to delete item from Open With list?
I want to remove the Windows media player from the open with list. (When i right click on a video file i have a choice to choose a player,so i want to remove the Windows media player from that list)
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...
Delete All Entries In The Common Feed List At Once
I imported my RSS/Feed list in IE8. I have over 200 entries in my Common Feed List and I want to start over with just a select few. So first I want to delete all entries. My question is this. Is there a way to delete everything in the common feed list at once? I know how to do one at a time but...
Browsers & Mail

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 06:32.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App