How to delete file using deep search in Windows XP?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
doscode
Posts: 175
Joined: 15 Feb 2012 14:02

How to delete file using deep search in Windows XP?

#1 Post by doscode » 14 Jun 2016 13:32

I have small disk space on one partition. In one folder there is lot of folders and sub-folders which sometimes contain a lot of files of these extensions:

*.ilk, *.pdb, *.exp , I would like to delete these files but not to do it manually because that can be dangerous (I could simply delete other files which should not be touched). What is the safe way how delete these files in subfolders? Also placing bat file to every folder is not good idea because I create new directories and that would be complicated.

sambul35
Posts: 192
Joined: 18 Jan 2012 10:13

Re: How to delete file using deep search in Windows XP?

#2 Post by sambul35 » 14 Jun 2016 16:23

Copying, moving, deleting files is easy with Robocopy, its included with OS and accessible from a batch. In Cmd window type robocopy /? to see available options for your OS version. In Win10 there's '/IF :: Include the following files' option, where you can list *.ilk, *.pdb, *.exp, but /IF isn't strictly required. See more Robocopy config examples here.

Your above batch may look like this to check all multilevel folders under My_Folder for target files, move the files and their empty folders (if any) to Deleted folder, then delete that folder (don't try moving to Recycled Bin):

Code: Select all

@echo off
setlocal
set "source=K:\My_Folder" & set "dest=K:\Deleted" & set "log=K:\My_Folder\RoboLog.txt"
set "options=/R:3 /W:20 /LOG+:%log% /NFL /NDL"
set "what=/COPYALL /B /TEE /MAXAGE:7 /S /MOVE *.ilk, *.pdb, *.exp"

robocopy %source% %dest% %what% %options%
if exist %dest% (rd /s /q %dest%)

endlocal
exit /b

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to delete file using deep search in Windows XP?

#3 Post by foxidrive » 15 Jun 2016 00:02

Make sure that "d:\folder" is correct and it exists.

Code: Select all

cd /d "d:\folder"
del /s *.ilk *.pdb *.exp

doscode
Posts: 175
Joined: 15 Feb 2012 14:02

Re: How to delete file using deep search in Windows XP?

#4 Post by doscode » 15 Jun 2016 01:47

On Windows XP I cannot find the program. robocopy /? command does not exist.

RE: Foxidrive: That sounds quite easy. Thanks

It works like sharm:

Code: Select all

@cls
cd /d ".\"
del /s *.ilk *.pdb *.exp
pause


I place it to folder where and which subfolders I need to clear.

sambul35
Posts: 192
Joined: 18 Jan 2012 10:13

Re: How to delete file using deep search in Windows XP?

#5 Post by sambul35 » 15 Jun 2016 05:45

Robocopy for XP is part of this Resource Kit. I prefer using it since it allows various file ops in a single batch when called as a function. :wink:

Post Reply