Batch file Help with deleting.

November 10, 2010 at 02:22:42
Specs: Windows XP
Have edited this batch file, but it deletes the entire contents of the New folder, while i want it to just delete any file with a .exe extension.

@echo off
for /f "tokens=*" %%j in (' dir "C:\Documents and Settings\robert.morland\Desktop\New Folder" /B /s *.exe') do del /Q "%%j"

See More: Batch file Help with deleting.

Report •

November 10, 2010 at 02:57:07

@del "C:\Documents and Settings\robert.morland\Desktop\New Folder\*.exe" /S /Q

Report •

November 10, 2010 at 04:04:35

Would it be possible to delete, say files with a .exe extension which are larger than say 2mb automatically delete but under 2 mb prompt to be deleted.

color 4F
mode con: cols=120 lines=50
@del "C:\Documents and Settings\robert.morland\Desktop\New Folder\*.exe"

/S /Q /P

Report •

November 11, 2010 at 03:37:57
@echo off
pushd C:\Documents and Settings\robert.morland\Desktop\New Folder 
for /F "delims=" %%j in ('dir *.exe /S /B') do (
  if %%~zj gtr 2097152 (del "%%~fj") else (del "%%~fj" /P)

Report •
Related Solutions

Ask Question