Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Don't you think "in several directories" is too much vague?
Anyway, the following batch file will delete all files named "filename.ext" which are on or under the directory "c:\main" (those values may be changed, read commented lines):
===== BATCH SCRIPT BEGIN =====
@echo off
if "%1"=="GoTo:" GOTO %2
if not "%OS%"=="" goto eof
%COMSPEC% /e:2048 /c %0 GoTo: start
goto eof
:start
set Q=
if not "%windir%"=="" set Q="
set dircmd=:: To activate the script, remove
:: "echo.{demo}" from next line
prompt echo.{demo}DEL %Q%:: Set location to look for files (c:\main)
:: and filename (filename.ext) below
:: ******************************
:: IMPORTANT: THE EXTENTION FROM
:: THE FILE MUST **NOT** BE AN
:: AN EXECUTABLE (COM EXE or BAT)
:: ******************************
dir/b/s/a-d c:\main\filename.ext> %TEMP%.\T1.BATctty nul
%COMSPEC% /c %TEMP%.\T1.BAT > %TEMP%.\T2.DAT
ctty con
FIND "\" < %TEMP%.\T2.DAT > %TEMP%.\T1.BAT
call %TEMP%.\T1.BAT
for %%? in (T1.BAT T2.DAT) do del %TEMP%.\%%?
:eof
===== BATCH SCRIPT END =====Watch out for line wrapping! The script is de-activated. When you run it, it will display a demonstration of the actions it would take if active. If those are the intented actions, activate the script (read commented lines to do so).
That script is for Win9x/DOS only, not NT systems. On those, use this:
for /R %I in (.\filename.ext) do if exist %I del %I
That would be run from the command prompt, under the directory where the files to be deleted are (it will look on subdirectories). If you intend to put that into a batch file, replace %I for %%I
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |