April 12th, 2006, 04:19 PM
Any Batch file Programmers here?!
I know this might sound easy but I've made an ussessful attempt to script in dos batch file something very simple. The idea is I have some directories (lets say four of them) and I want to delete 3 bogus ones, I already know the good one and have stored its name in a variable %DIREC%. for example
Directory of C:\dev
04/12/2006 04:18 PM <DIR> .
04/12/2006 04:18 PM <DIR> ..
04/12/2006 04:18 PM <DIR> good
04/12/2006 04:18 PM <DIR> random11
04/12/2006 04:18 PM <DIR> random2
04/12/2006 04:18 PM <DIR> random3
0 File(s) 0 bytes
6 Dir(s) 18,289,057,792 bytes free
the good corresponds to %DIREC%.
Any ideas? Thanks
April 16th, 2006, 08:44 AM
This might need a few tweaks
The first part gets a list of all the directory names in the current dir.
for /d %i in (*) do (
if not "%i" == "%DIREC%" del /s %i
The second part deletes those dirs which do not match.