deleting files but leaving folders intact

G

Guest

Greetings

I would like to know how to delete files & folders inside a specific folder
without having to manualy go into each folder and delete it myself, reason
being is there are over 1600 of them....

The existing structure is like this

studentsprofiles$\year\%username%\ <-anything below this needs to be deleted.

The folder %username% is a default users profile folder, i need to delete
whats in this folder but to keep the main profile folder with its permissions.

Please could anyone let me know how this can be done via script(which i dont
know how to do) or batchfile..

Many thanks.
 
J

Jerold Schulman

Greetings

I would like to know how to delete files & folders inside a specific folder
without having to manualy go into each folder and delete it myself, reason
being is there are over 1600 of them....

The existing structure is like this

studentsprofiles$\year\%username%\ <-anything below this needs to be deleted.

The folder %username% is a default users profile folder, i need to delete
whats in this folder but to keep the main profile folder with its permissions.

Please could anyone let me know how this can be done via script(which i dont
know how to do) or batchfile..

Many thanks.


See Deltree at tip 617 in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
 
R

R. C. White

Hi, James.

I'm not sure I understand your whole problem, but in your batch file (run
from the "DOS" window or a Command Prompt, I assume), you can use the rd (or
rmdir) command with the /s parameter. As with any command in the "DOS"
window, type the command followed by /? to see a mini-Help file showing all
the switches and parameters available with that command.

Rd /? shows only /s and /q. The /s switch removes the named folder,
including all the files and subfolders within it, after asking "Are you
sure?" The /q skips the question and removes it all immediately.

I don't really recall how to do this for many different <foldernames> in
succession, because I haven't written any serious batch file in years. You
would use a for...next loop, feeding it a folder name at a time from a list
in a text file, I suppose, but I'll leave this step for someone else. ;^}

Hmm... I reread your question. It asks about profiles and permissions,
which I know nothing about. (As just one guy with one computer and no user
but me, I haven't had to learn about those.)

RC
 
G

Guest

Thanks for all your help guys. I know batch files reasonably well. I will
give it a try.

regards
James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top