Batch File: help with for script - Programmers Heaven

Howdy, Stranger!

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

Categories

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.