Help with IF NOT Problem
Posted: 16 Apr 2008 14:08
i am working on some code that works fine when I am not testing with IF NOT, but when I have the IF NOT statements in, the code only loops once, then stops working.
the file gameList.txt looks something like
and then the script I am using looks like this
Now I know it works as like I said, when I find the files it says what directory it is going to delete. The only problem is when I am testing it, it only loops through once and then stops working as if it didn't see the other two lines.
the file gameList.txt looks something like
Code: Select all
name1.exe
name2.exe
name3.dll
and then the script I am using looks like this
Code: Select all
@echo off
setlocal enabledelayedexpansion
c:
cls
echo *********************************************
echo **Delete Given File Names that can Be found**
echo *********************************************
echo Studying the file for banned file names.
for /f %%A in (H:\gameLocations\gameList.txt) do (
set filename=%%A
echo Searching for !filename!
title Searching...
for /f "delims==" %%D in ('dir /s /b "!filename!"') do (
set direc=%%~dpD
IF "!direc!"=="C:\Windows\*" Goto skip
:check
IF "!direc!"=="C:\Program Files\" Goto skip2
:continueScript
echo !filename! found in folder !direc!
echo removing files/folder
echo rmdir /s /q "!direc!" && echo OK
Goto endScript
:skip
echo Found in the Windows Directory (Not Deleting...)
Goto endScript
:skip2
echo Found in the Program Files Directory (Not Deleting...)
:endScript
)
echo Searching Hidden Files and Folders for !filename!
for /f "delims==" %%D in ('dir /s /b /a:H "!filename!"') do (
set direc=%%~dpD
IF "!direc!"=="C:\Windows\*" Goto skip
:check
IF "!direc!"=="C:\Program Files\" Goto skip2
:continueScript
echo !filename! found in folder !direc!
echo removing files/folder
echo rmdir /s /q "!direc!" && echo OK
Goto endScript
:skip
echo Found in the Windows Directory (Not Deleting...)
Goto endScript
:skip2
echo Found in the Program Files Directory (Not Deleting...)
:endScript
)
)
pause
Now I know it works as like I said, when I find the files it says what directory it is going to delete. The only problem is when I am testing it, it only loops through once and then stops working as if it didn't see the other two lines.