Del all occurances of a name

July 15, 2010 at 01:10:06
Specs: Windows XP, 2gb
Can I redirect(pipe) more than two commands in dos? eg. I got this command:
dir /s /b | find /I "John"
which outputs a list of all dir/files which contains John, now I want to use that output and run it through del. something like
dir /s /b | find /I "john" | del
but this doesn't work.
Any ideas?

See More: Del all occurances of a name

Report •

July 15, 2010 at 05:06:18
download findutils for windows, then do this

c:\> gnu_find.exe c:\path -type f -iname "*John" -delete

GNU win32 packages | Gawk

Report •

July 15, 2010 at 11:59:10
batch version:
@echo off
for /f "tokens=*" %%a in ('dir /s /b ^| find /I "John"') do del %%a
::----- end
be careful! do a dry run (using echo) first!

Report •

July 15, 2010 at 12:13:13
Easier batch version:
del /s *john*

EDIT: Assuming you want to delete any file with "John" in the name, and not every file in some folder with "John" in it, as well as every file with "John" in its name. If not, stick with nbrane's script.

Report •

Related Solutions

Ask Question