Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Batch File: help with for script

sajusticesajustice Posts: 2Member
All I found this script online that works great.

REM *************Begin**************

SET SRC1=C:Documents and Settings
SET SRC2=Local SettingsTemporary Internet FilesContent.IE5
FOR /D %%X IN ("%SRC1%*") DO FOR /D %%Y IN ("%%X%SRC2%*.*") DO RMDIR /S /Q "%%Y"


REM **************end***************

I want to edit it to clean some more items. This is the file I have created.

REM *************Begin********************

SET SRC1=C:Documents and Settings
SET SRC2=Local SettingsTemporary Internet FilesContent.IE5
SET SRC3=cookies
SET SRC4=Local SettingsTemp


REM Del Quarantined SEP files
Echo Deleting Symantec Temp Files
del C:"Documents and Settings""All Users""Application Data"Symantec"Symantec Endpoint Protection"Quarantine*.* /f /q /s

rem del windows temp files
Deleting Windows Temp Files
del c:%systemroot% emp*.* /f /q /s

rem del src2 temporary internet files
FOR /D %%X IN ("%SRC1%*") DO FOR /D %%Y IN ("%%X%SRC2%*.*") DO RMDIR /S /Q "%%Y"

del src3 cookies
FOR /D %%X IN ("%SRC1%*") DO FOR /D %%Y IN ("%%X%SRC3%") DO DEL *.* /F /S /Q "%%Y"


FOR /D %%X IN ("%SRC1%*") DO FOR /D %%Y IN ("%%X%SRC4%*.*") DO RMDIR *.* /S /Q "%%Y"

del src4 temp files
FOR /D %%X IN ("%SRC1%*") DO FOR /D %%Y IN ("%%X%SRC4%") DO DEL *.* /F /S /Q "%%Y"



REM **************end***************



I know the problem is with the /D command.

What I want is for the the contents of the cookies folder to be deleted, all folders in the temp directory to be deleted and all the files in the temp root directory to be deleted.

From online reading it looks like if I make the following change

FOR /D %%X IN ("%SRC1%*") DO FOR /F %%Y IN ("%%X%SRC4%") DO DEL *.* /F /S /Q "%%Y"

This would work, but it is not working for me.

Can someone assist?
Sign In or Register to comment.