File explorer/search very slow in deleting 10000s of files

  • Thread starter Thread starter John Dalberg
  • Start date Start date
J

John Dalberg

I have a folder which has about 250000 text files most of them need to be
deleted. I am using file explorer and it search to delete the files that
contain a certain string of text but the delete process hangs because for
some reason the search gets triggered again byitself and the delete is
still running and the whole system becomes dang slow.

So is there a better way to search and delete out of file explorer?
Something like in dos and with grep. I am not proficient in dos commands.

Thanks.

John Dalberg
 
I have a folder which has about 250000 text files most of them need to be
deleted. I am using file explorer and it search to delete the files that
contain a certain string of text but the delete process hangs because for
some reason the search gets triggered again byitself and the delete is
still running and the whole system becomes dang slow.

So is there a better way to search and delete out of file explorer?
Something like in dos and with grep. I am not proficient in dos commands.

Thanks.

John Dalberg

Save the following as DeleteThem.bat

At a CMD.EXE window, run:
DeleteThem "FolderPath" "text string"

@echo off
if {%2}=={} @echo DeleteThem Folder Text&goto :EOF
if not exist %1 @echo DeleteThem - Fold %1 does NOT exist.&goto :EOF
setlocal
set folder=%1
set folder=%folder:"=%#
set folder=%folder:\#=%
set folder=%folder:#=%
set txt=%2
set txt=%txt:"=%
for /f "Tokens=*" %%a in ('dir "%folder%\*.txt" /b /s /a') do (
for /f "Tokens=*" %%b in ('type "%%a"^|find /i "%txt%"') do (
del /q "%%a"
)
)
popd
endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
I wasn't sure but it sounded like text within the file not the file name.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Save the following as DeleteThem.bat
|
| At a CMD.EXE window, run:
| DeleteThem "FolderPath" "text string"
|
| @echo off
| if {%2}=={} @echo DeleteThem Folder Text&goto :EOF
| if not exist %1 @echo DeleteThem - Fold %1 does NOT exist.&goto :EOF
| setlocal
| set folder=%1
| set folder=%folder:"=%#
| set folder=%folder:\#=%
| set folder=%folder:#=%
| set txt=%2
| set txt=%txt:"=%
| for /f "Tokens=*" %%a in ('dir "%folder%\*.txt" /b /s /a') do (
| for /f "Tokens=*" %%b in ('type "%%a"^|find /i "%txt%"') do (
| del /q "%%a"
| )
| )
| popd
| endlocal
|
| Jerold Schulman
| Windows Server MVP
| JSI, Inc.
| http://www.jsiinc.com
| http://www.jsifaq.com
 
I wasn't sure but it sounded like text within the file not the file name.

Yes, that was what my script located.

:
| Save the following as DeleteThem.bat
|
| At a CMD.EXE window, run:
| DeleteThem "FolderPath" "text string"
|
| @echo off
| if {%2}=={} @echo DeleteThem Folder Text&goto :EOF
| if not exist %1 @echo DeleteThem - Fold %1 does NOT exist.&goto :EOF
| setlocal
| set folder=%1
| set folder=%folder:"=%#
| set folder=%folder:\#=%
| set folder=%folder:#=%
| set txt=%2
| set txt=%txt:"=%
| for /f "Tokens=*" %%a in ('dir "%folder%\*.txt" /b /s /a') do (
| for /f "Tokens=*" %%b in ('type "%%a"^|find /i "%txt%"') do (
| del /q "%%a"
| )
| )
| popd
| endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
Back
Top