1.

Solve : run code if folder(s) exist?

Answer»

i am USING the following code to clean up IE, but SOMETIMES the code does not run properly. i would like to pass the code through a if exists CHECK, then run the code:

FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Cookies\*.*" >> C:\BackUpHistory\Report.txt
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\Temp\*.*" >> C:\BackUpHistory\Report.txt
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\History\*.*" >> C:\BackUpHistory\Report.txt
FOR /D %%G IN ("C:\Documents and Settings\*.*") DO DEL/S/Q/F "%%G\Local Settings\Temporary Internet Files\*.*" >> C:\BackUpHistory\Report.txt

the best that i can FIGURE out is the code stops working when it comes to a user's profile where the appropriate folder does not exist.
if the proflile or user name jat does not have any of the folders, all of the profiles before Jat are cleaned, but after Jat, nothing gets cleaned. i wold like to pass each of the 4 lines of code throught an if exist then ...

any help would be appreciated,

jat
You need the if command.
Or here.Here:

If exist FOLDERNAME (
commands
commands
)



Discussion

No Comment Found