Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Recursive File Delete

Reply
Thread Tools Display Modes

Recursive File Delete

 
 
Buck Turgidson
Guest
Posts: n/a

 
      11-06-2009
I need to delete files from a subdirectory under a bunch of profiles. In
other words, I have users john, jim, and jill as

c:\documents and settings\john
c:\documents and settings\jim
c:\documents and settings\jill

And each of their profiles has a subdirectory called apps. In each apps
file for them, I need to delete all .txt files, but only from the apps
subdirectory of their profile.

c:\documents and settings\john\apps
c:\documents and settings\jim\apps
c:\documents and settings\jill\apps

Can anyone help me?


 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a

 
      11-06-2009

"Buck Turgidson" <> wrote in message
news:hd1ua1$eeb$...
>I need to delete files from a subdirectory under a bunch of profiles. In
>other words, I have users john, jim, and jill as
>
> c:\documents and settings\john
> c:\documents and settings\jim
> c:\documents and settings\jill
>
> And each of their profiles has a subdirectory called apps. In each apps
> file for them, I need to delete all .txt files, but only from the apps
> subdirectory of their profile.
>
> c:\documents and settings\john\apps
> c:\documents and settings\jim\apps
> c:\documents and settings\jill\apps
>
> Can anyone help me?


By far the simplest method is based on a batch file like so:
@echo off
for %%a in (John Jim Jill) do del /s "c:\Documents and
Settings\%%a\apps\*.txt"

Since the command consists of a single line, you could even type it at the
Command Prompt like so:
for %a in (John Jim Jill) do del /s "c:\Documents and
Settings\%a\apps\*.txt"
Note the double versus single % characters.

Or maybe this:
del /s "c:\Documents and Settings\John\apps\*.txt"
del /s "c:\Documents and Settings\Jill\apps\*.txt"
del /s "c:\Documents and Settings\Jim\apps\*.txt"


 
Reply With Quote
 
Buck Turgidson
Guest
Posts: n/a

 
      11-06-2009
Thanks for the help. The problem is that the actual number of profiles is
both variable and quite large. I guess that is the toughest nut to crack.




"Pegasus [MVP]" <> wrote in message
news:...
>
> "Buck Turgidson" <> wrote in message
> news:hd1ua1$eeb$...
>>I need to delete files from a subdirectory under a bunch of profiles. In
>>other words, I have users john, jim, and jill as
>>
>> c:\documents and settings\john
>> c:\documents and settings\jim
>> c:\documents and settings\jill
>>
>> And each of their profiles has a subdirectory called apps. In each apps
>> file for them, I need to delete all .txt files, but only from the apps
>> subdirectory of their profile.
>>
>> c:\documents and settings\john\apps
>> c:\documents and settings\jim\apps
>> c:\documents and settings\jill\apps
>>
>> Can anyone help me?

>
> By far the simplest method is based on a batch file like so:
> @echo off
> for %%a in (John Jim Jill) do del /s "c:\Documents and
> Settings\%%a\apps\*.txt"
>
> Since the command consists of a single line, you could even type it at the
> Command Prompt like so:
> for %a in (John Jim Jill) do del /s "c:\Documents and
> Settings\%a\apps\*.txt"
> Note the double versus single % characters.
>
> Or maybe this:
> del /s "c:\Documents and Settings\John\apps\*.txt"
> del /s "c:\Documents and Settings\Jill\apps\*.txt"
> del /s "c:\Documents and Settings\Jim\apps\*.txt"
>



 
Reply With Quote
 
Buck Turgidson
Guest
Posts: n/a

 
      11-06-2009
Thanks.

for /d %a in (*)

seems to do it, if not a bit crudely.





"Pegasus [MVP]" <> wrote in message
news:...
>
> "Buck Turgidson" <> wrote in message
> news:hd1ua1$eeb$...
>>I need to delete files from a subdirectory under a bunch of profiles. In
>>other words, I have users john, jim, and jill as
>>
>> c:\documents and settings\john
>> c:\documents and settings\jim
>> c:\documents and settings\jill
>>
>> And each of their profiles has a subdirectory called apps. In each apps
>> file for them, I need to delete all .txt files, but only from the apps
>> subdirectory of their profile.
>>
>> c:\documents and settings\john\apps
>> c:\documents and settings\jim\apps
>> c:\documents and settings\jill\apps
>>
>> Can anyone help me?

>
> By far the simplest method is based on a batch file like so:
> @echo off
> for %%a in (John Jim Jill) do del /s "c:\Documents and
> Settings\%%a\apps\*.txt"
>
> Since the command consists of a single line, you could even type it at the
> Command Prompt like so:
> for %a in (John Jim Jill) do del /s "c:\Documents and
> Settings\%a\apps\*.txt"
> Note the double versus single % characters.
>
> Or maybe this:
> del /s "c:\Documents and Settings\John\apps\*.txt"
> del /s "c:\Documents and Settings\Jill\apps\*.txt"
> del /s "c:\Documents and Settings\Jim\apps\*.txt"
>



 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a

 
      11-06-2009

"Buck Turgidson" <> wrote in message
news:hd205c$vcl$...
> Thanks.
>
> for /d %a in (*)
>
> seems to do it, if not a bit crudely.


Indeed it does - congratulations for working it out for yourself! For your
next post I recommend that you state *all* requirements right in the
beginning.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't delete or move file anne Windows Vista File Management 4 03-17-2009 07:50 AM
File Won't Delete Stuart Windows Vista File Management 1 12-18-2006 12:55 AM
Re: Under what conditions does ActiveSync DELETE a file on the Pocket PC? Sven ActiveSync 0 08-13-2006 08:06 PM
Re: Under what conditions does ActiveSync DELETE a file on the Pocket PC? Juggs Ravalia \(MS\) ActiveSync 1 08-13-2006 03:22 PM
cannot delete file on pocket pc Stonewall ActiveSync 1 01-11-2005 10:44 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59