1.

Solve : Batch Delete?

Answer»

I am looking to create a batch that can will delete files permanently.

The problem is I want to search for several file extensions (.xls, .zip, .txt).

These files will appear within a sub directory of a folder called "download". The download folder will exists in about 20 folder structures.

EG You could have a folder called A which has a folder within that called Download, and a folder within that called test which will contain the files. You can then have another folder called B on the same LEVEL as A that contains the same structure as A?

Any ideas? Batch language is not a programming language. But since everyone seems to think that it is, I OFFER this primitive solution:

Code: [Select]

@echo off
:start
if .%1==. goto end
for /f "tokens=1*" %%a in ('dir foldername /a:d /b /s ^| find /i "download"') do (
for /f "tokens=1*" %%i in ('dir "%%a\*.%1" /b') do (
echo %%a\%%i
)
)
shift
goto start

:end


This solution is quirky at best. It's also a self feeder. Pass the file extensions along the command line. Replace foldername with a folder of your choice.

Note: I am HESITANT to show posters how to delete files. As written, the file will simply echo back what would be deleted...change echo to del at your own risk. Files deleted thru batch files and scripts do not make a pit STOP in the recycle bin.

Good luck and next TIME mention your OS (it's not a state secret) and consider Win Scripting as a better and more robust solution.



Discussion

No Comment Found