|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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 ![]() |
|
#2
|
||||
|
||||
|
This might need a few tweaks
Code:
for /d %i in (*) do ( if not "%i" == "%DIREC%" del /s %i ) The first part gets a list of all the directory names in the current dir. The second part deletes those dirs which do not match.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Any Batch file Programmers here?! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|