[windows2000] Re: Removing contents of a directory

  • From: "Drew S" <drew2@xxxxxxxxxxxx>
  • To: <windows2000@xxxxxxxxxxxxx>
  • Date: Tue, 30 Mar 2004 00:44:58 -0500

Glenn -

Two problems with this method:

A) I can't figure out how to handle spaces in file names... I know that this
won't be an issue with particular implementation, but I'm always trying to
figure things out the way that is most compatible

B) This only deletes the files themselves - not the subdirectories entirely.
I need that to happen too. Basically, I need to purge EVERYTHING that this
user has done to this directory, including creation of folders/directories.

Chris -

Yeah... I would have taken it to a Novell list if I needed help with file
access rights... but I know how to do that anyway. :)

A) Only purges files in $username
B) Same as above; need all subdirectories and files therein purged.

As I'm not very familiar with Perl... I could be wrong, but I don't believe
I am.

I apologize for asking for help with this one... if I had my
MS-DOS/Scripting reference manual I'm sure I could figure it out, but that's
in my second office, about 20 miles south of me right now. I've written
scripts for a TON of things. I've also been going on just a couple of hours
of sleep each night. :( I'm normally more intuitive but I've dropped the
ball on this one.

Drew

-----Original Message-----
From: windows2000-bounce@xxxxxxxxxxxxx
[mailto:windows2000-bounce@xxxxxxxxxxxxx] On Behalf Of Sullivan, Glenn
Sent: Tuesday, March 30, 2004 12:01 AM
To: windows2000@xxxxxxxxxxxxx
Subject: [windows2000] Re: Removing contents of a directory

Combine the FOR command and the DIR command.

DIR <directory> /b /s /a-d

Lists a given directory and all subdirectories, with no headers or other
crap... just the full path and filename.

Throw that into a for /f statement, and you get:

FOR /f %i in ('dir <directory> /b /s /a-d') do del /f "%i"

Change the "del /f" to "echo" or "del /p" if you just want to test.

And if you want it in a .cmd file, you would need to double up the percent
signs, like so:

FOR /f %%i in ('dir <directory> /b /s /a-d') do del /f "%%i" 

Hope this helps,

Glenn Sullivan, MCSE+I  MCDBA
David Clark Company Inc. 

-----Original Message-----
From: windows2000-bounce@xxxxxxxxxxxxx
[mailto:windows2000-bounce@xxxxxxxxxxxxx]On Behalf Of Drew S
Posted At: Monday, March 29, 2004 11:31 PM
Posted To: Windows 2000
Conversation: [windows2000] Removing contents of a directory
Subject: [windows2000] Removing contents of a directory


Hey all... I *should* know of a way to do this, but don't.

Here's the scenario:

I need a way to purge the contents of a certain directory (folder), so that
all files, subdirectories, etc., EVERYTHING is removed from this folder. I
would normally just RMDIR the directory and then recreate it. However, there
are network permissions declared explicitly on this directory, and I can't
afford to have to apply those permissions again, manually. A little more
detail:

Say our user accounts are at:
\\server0\data\users\department\%username%\
Also mapped as i:\users\department\%username% for admins

I need the admins to be able to purge all of the contents of their user
directory (the path listed above), but they cannot purge the directory
itself, as it would be very laborious to manually define each folder's user
permission. Is there a way to tell the system to recursively remove
everything so that it removes everything under the user folder? I don't want
*ANYTHING* to exist under the %username% folder. We are not, however,
purging the data for all usernames - just specific ones. They do happen to
be sequential, though.

BTW, this network uses Novell Netware instead of Windows 2000 Active
Directory, just in case you were thinking of any windows 2000 solutions. All
clients are Windows XP.

I feel stupid for asking this... seems like a very simple problem. I'd like
to integrate this into a batch script so that when the time comes to do this
all over again (this will need to be done like once every 2 months), the
admin can just run the batch file and all of the user files will be purged.
I will, of course, build a safety feature in so that the admin can't
accidentally run the script and make a lot of people angry.

Drew

********************************************************
This Weeks Sponsor StressedPuppy.com Games
Feeling stressed out? Check out our games to
relieve your stress.
http://www.StressedPuppy.com
********************************************************
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm
********************************************************
This Weeks Sponsor StressedPuppy.com Games
Feeling stressed out? Check out our games to
relieve your stress.
http://www.StressedPuppy.com
********************************************************
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm



__________ NOD32 1.693 (20040325) Information __________

This message was checked by NOD32 Antivirus System.
http://www.nod32.com


********************************************************
This Weeks Sponsor StressedPuppy.com Games
Feeling stressed out? Check out our games to
relieve your stress.
http://www.StressedPuppy.com
********************************************************
To Unsubscribe, set digest or vacation
mode or view archives use the below link.

http://thethin.net/win2000list.cfm

Other related posts: