Windows Server - Recursive File Delete
Asked By Buck Turgidson
06-Nov-09 02:43 PM
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?
Profiles
(1)
Toughest
(1)
Offfor
(1)
Jill
(1)
Apps
(1)
Pegasus [MVP] replied to Buck Turgidson
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"
Buck Turgidson replied to Pegasus [MVP]
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.
Buck Turgidson replied to Pegasus [MVP]
Thanks.
for /d %a in (*)
seems to do it, if not a bit crudely.
Pegasus [MVP] replied to Buck Turgidson
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.

have a server 2003 standard with TS and AD setup on the one box. user profiles are local to this machine. We now want to seperate the AD from this machine swung to the new machine and AD removed from the old machine will the user profiles on the old machine be preserved ? I think the steps would be 1. swing AD AD 3. join server1 to AD Windows Terminal Services Discussions Documents and settings (1) User profiles (1) Temp server (1) AD (1) The location of the profiles is specified in a group policy or in the AD settings per user, and has nothing to do with the location of the AD. You can have your profiles on any server that is a member of the domain. Thanks for your comments. my issue is I WANT to re use the user profiles on server1 as they contain outlook settings, desktop, etc. I am concerned that after step settings. this seems to come close to C: \ documents and settings? You DO have roaming profiles, do you? f No, as server1 is the only server at the moment the profiles are local. i have rethought the issue and am thinking if i make the profiles
make this conistent also? I have confirmed that all users are set up with roaming profiles - and from what I can tell, they seem to be set up correctly and the setup. If I log on to the server as administrator, and go to \ server-name \ profiles$ \ and try to open a user's folder, I get the message If I try Discussions Vista (1) XP (1) LimitLogon (1) Workstationand (1) Favourites (1) Conistent (1) Printers (1) Profiles (1) Do not let users roam between different OSes. All workstations should be running the load if they are going to roam at all. it is OK to use roaming profiles even for nonroaming users (it makes it so easy to replace a workstation or restore someone's profile data) though. Roaming profiles. Read on. . . Same. Apparently not :) Check for userenv errors in the application event logs on This is not an SBS thing, for what it is worth - it is AD. Roaming profiles are great if you know how to do it right. . . . but most people do not, in my experience. Sounds like your roaming profiles were not created 100% properly / ideally. Here is my boilerplate. Re permissions, if you are handy with XCACLS you can add the administrators group to the existing profiles (or you can take ownership as Administrators & manually add the Administrators & <username> with full control
Server I am having an occasional problem with our SBS2003 domain. When users with roaming profiles log off, sometimes their ntuser.dat file will have its permissions corrupted and they will Discussions XP (1) LimitLogon (1) Workstationand (1) Boilerplate (1) Problemsat (1) Directory (1) Enteries (1) Profiles (1) Sure, you could set up a logoff script, but if they are having problems the problem, which is with your roaming profile setup. Check out my boilerplate on roaming profiles. Don't use them unless you are sure you have got them set up rock-solidly. . . General tips: 1. Set up a share on the server. For example - d: \ profiles, shared as profiles$ to make it hidden from browsing. Make sure this share is *not* set to allow caching! (that is on by default - disable it) 2. Make sure the share permissions on profiles$ indicate everyone = full control. Set the NTFS security to administrators, system, and users = full control. 3. In the users' ADUC properties, specify \ server \ profiles$ \ %username% in the profiles field 4. Have each user log into the domain once - if this is an existing
1) Windows (1) Docs (1) Workstationand (1) Boilerplate (1) Solvesthe (1) Directory (1) Yes, humongous profiles are a problem. However, if you redirect the My Documents folder (and do not exclude away with it (test to see if that works). Here is my boilerplate on roaming profiles (which you are not using but could be) and folder redirection (which you should use). * ** ** ** ** ** ** ** ** ** * General tips: 1. Set up a share on the server. For example - d: \ profiles, shared as profiles$ to make it hidden from browsing. Make sure this share is *not* set to allow caching! (that is on by default - disable it) 2. Make sure the share permissions on profiles$ indicate everyone = full control. Set the NTFS security to administrators, system, and users = full control. 3. In the users' ADUC properties, specify \ server \ profiles$ \ %username% in the profiles field 4. Have each user log into the domain once - if this is an existing now roaming. 5. If you want the administrators group to automatically have permissions to the profiles folders, you will need to make the appropriate change in group policy. Look in computer
SBS 2003 - Remove Roaming Profiles Windows Server Can anyone outline the best practice for removing roaming profiles for selected users, reverting them to local profiles only? I have inherited a client in which some of the users have been set up for roaming profiles (by setting the profile paths in their ADUC properties) in a working environment which is inappropriate (for roaming profiles, that is), and want to change them back to local profiles. The built-in administrator's profile is also set to roaming, and I want that back as a local profile. Windows Server SBS Discussions Profiles (1) Paths (1) ADUC (1) SBS (1) Assuming the roaming profiles were set up properly, you should be able to remove the profile path in ADUC