Re: Delete all files in certain folders across multiple users

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Rhenestofel" <rhenestofel@xxxxxxxxx> wrote in message
news:78070349-9c70-4a60-bdd0-568315f80c23@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What I am actually trying to do is use this on a computer to help
speed up the clean out process. I am trying to create this script for
side jobs I do where I have to go into Doc's & Settings and each user
acct and clear these directories out manually, this can take a while
if there are multiple users on a single machine. I want to keep the
active user's files and profile just rid the system of all users temp-
data/cookies/history. As for directories vs. directory trees, I would
like to delete all data in these directories. The part it seems to get
hung at is that some accts do not have these directories and it causes
it to error out. It generally does the "Administrator" acct fine but
then it hits the "all users" directory and errors out.

I am kinda new to scripting at all, so this is an exercise in
scripting period. If a batch file would be a better way to go, can you
please let me know where to turn for information? I have looked at a
few sites on batch files but don't see anything that quite fits my
situation.

This little batch file will what you want. If some folders do not
exist then the batch file will move on to the next folder or user.

@echo off
cd /d "%AllUsersProfile%\.."
set Docs=%CD%
for /d %%a in (*.*) do call :Del %%a
goto :eof

:Del
echo Cleaning up user "%*"
echo rd /s /q "%Docs%\%*\Cookies"
echo md /s /q "%Docs%\%*\Cookies"

echo rd /s /q "%Docs%\%*\Local Settings\History\History.IE5"
echo md /s /q "%Docs%\%*\Local Settings\History\History.IE5"

echo rd /s /q "%Docs%\%*\Local Settings\Temp"
echo md /s /q "%Docs%\%*\Local Settings\Temp"

echo rd /s /q "%Docs%\%*\Local Settings\Temporary Internet Files"
echo md /s /q "%Docs%\%*\Local Settings\Temporary Internet Files"

echo rd /s /q "%Docs%\%*\UserData"
echo md /s /q "%Docs%\%*\UserData"

You must determine if it is safe to delete the folders you specified.
Run the batch file as it is to check if it would to the right thing when
activated. To activate it, remove the word "echo" in front of every
"rd" and "md" command.

If you need any further advice, try to respond a little more quickly,
before this thread disappears from the horizon of my newsreader.


.



Relevant Pages

  • Re: Trying to organize 3k+ folders with a script
    ... images, and they need to be organized into folders by year, then ... Not every day has images. ... echo All done! ... Run the batch file in its "pretend" mode. ...
    (microsoft.public.scripting.vbscript)
  • Re: Trying to organize 3k+ folders with a script
    ... images, and they need to be organized into folders by year, then ... Not every day has images. ... echo All done! ... Press each time the batch file pauses. ...
    (microsoft.public.scripting.vbscript)
  • Re: Script to check individual permissions
    ... You can try this batch file. ... echo Compiling a directory listing ... I want to clean up the permissions on my fileserver. ... only displays that folders with permissions set to individual users. ...
    (microsoft.public.windows.file_system)
  • Re: Command line : how to get the .cmd file name Im running
    ... I tried to use %CD%, but it seems that if the startup directory is a UNC share, it is unusable. ... (in a batch file, %0 is the path to the batch file including the batch ... @echo off ... torgeir, Microsoft MVP Scripting, Porsgrunn Norway ...
    (microsoft.public.windowsxp.general)
  • Re: How to know the PC domain
    ... I tried with batch file but i receive the message 'echo is off' and not the ... > Set colComputer = oWMI.ExecQuery _ ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windowsxp.configuration_manage)