Link to home
Start Free TrialLog in
Avatar of wasabi3689
wasabi3689Flag for United States of America

asked on

How do I delete

I have a folder with several sub direcrorries and then files, How can I run a Dos command to detele all MS Word file only .doc? Also, I want to log the output for the file deleted ( file names).
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill Prew
Bill Prew

Here's a small BAT script that will log file names.

@echo off

set BaseDir=c:\basefolder
set LogFile=c:\temp\dellog.txt

(
  for /f "tokens=*" %%A in ('dir /b /s /a-d "c:\basefolder\*.doc"') do (
    echo Deleting: %%A
    del "%%~A"
  )
)>"%LogFile%"

Open in new window

~bp