Question Locked

rmdir wildcards deltree

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Students have their own user accounts which get added to Docs & Settings on every WinXP Pro computer in the school that they use during the year. At the end of the year I would like to clear out (delete) their subdirectories. I found that rmdir /s will do what deltree did in DOS, but it does not accept wildcards. (All student user accounts start with a 1, 2, or 3.)
Is there any provision for wildcards that I'm missing, or is their a shareware utility that will do what we need?

3 replies

by Member 25348569

Use DOS 'For'

At the command prompt:

For /D %i in (X:\Path to folders\1*.*) do rmdir %i /S /Q

Will remove all folder beginning with 1, one at a time. Repeat the line with a 2, 3 and so on.

Note that this is from the command line, If you want to put the three lines in a batch file you will need to use %%i as the variable in both places.

For /D %%i in (X:\Path to folders\1*.*) do rmdir %%i /S /Q
For /D %%i in (X:\Path to folders\2*.*) do rmdir %%i /S /Q
For /D %%i in (X:\Path to folders\3*.*) do rmdir %%i /S /Q

Or even, if you're feeling a bit lairy,

For /L %i in (1,1,3) do for /D %j in (X:\Path to folders\%i*.*) do rmdir %j /S /Q

(%%i and %%j in a batch file)

Clunky but free. For /? to get some idea of what I'm suggesting.

Neil :D

Good old DOS; them were the days...

by bg

To delete profiles of all computers listed in text file pclist.txt

listed like this
\\pc01
\\pc02
\\pc03

create a batch file like this...
for /F %%i in (PCLIST.txt) do for /f "delims=" %%a in ('dir %%i\c$\"Documents and Settings"\*.ccl /b /ad') do rd /s /q %%i\c$\"Documents and Settings"\"%%a"

Hope this helps somone took a lot of time to work it out :)

Cheers
Bill Gates

This discussion is closed to new replies.