if not exist doesn't seem to be working

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

if not exist doesn't seem to be working

#1 Post by flaskvacuum » 01 Apr 2014 22:20

hi guys,
i can't to get it to work,
for /F "tokens=1*" %%i in (%File_dbname%) do (
for %%A in (%%j) do (
echo **********************************************************************>>%output-file%
echo %%A DB daily check ORA-ERROR at %%i>>%output-file%
echo **********************************************************************>>%output-file%
echo .>>%output-file%
echo .>>%output-file%

REM if NOT exist alert_%%A.log (
REM echo alert_%%A.log Not found>>%output-file%

REM )
:: print out all ORA- errors along with their associated timestamps
findstr /br "Sun\> Mon\> Tue\> Wed\> Thu\> Fri\> Sat\> ORA-[0-9]*" alert_%%A.log|findstr /r "!LF!ORA- ^ORA-">>%output-file%
If ERRORLEVEL 1 echo NO ORA- error found in alert_%%A.log>>%output-file%

echo .>>%output-file%
echo .>>%output-file%
IF NOT EXIST alert_%%.log echo no new alert_%%A.log generated>> %output-file%
)
)

basically is when it loop through the list of files (which is dynamically) and if that particular files is not found, it will says that particular log is not generated yet.
please help.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: if not exist doesn't seem to be working

#2 Post by foxidrive » 01 Apr 2014 23:06

IF NOT EXIST alert_%%.log

The %% needs something else there.

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: if not exist doesn't seem to be working

#3 Post by flaskvacuum » 02 Apr 2014 00:50

oh...hmm...ok...

i amend it as alert_%%A.log already. But seem to be still the same.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: if not exist doesn't seem to be working

#4 Post by foxidrive » 02 Apr 2014 02:41

Under the top line below, add the next two lines. Then run it and see what is being printed.

Code: Select all

IF NOT EXIST alert_%%A.log echo no new alert_%%A.log generated>> %output-file% 
echo IF NOT EXIST alert_%%A.log echo no new alert_%%A.log generated
pause

flaskvacuum
Posts: 43
Joined: 08 Mar 2013 11:23

Re: if not exist doesn't seem to be working

#5 Post by flaskvacuum » 02 Apr 2014 03:52

it start to print out those files that actually exist in the folder !!!
which should be printing those files that did not exist in the folder ! i am confuse.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: if not exist doesn't seem to be working

#6 Post by foxidrive » 02 Apr 2014 04:04

It will print out every line with that echo command.

Do any of the filenames have spaces or & characters in the filename?
Are there any error message as well?

aGerman
Expert
Posts: 4714
Joined: 22 Jan 2010 18:01
Location: Germany

Re: if not exist doesn't seem to be working

#7 Post by aGerman » 02 Apr 2014 11:10

Please post a typical line of your %File_dbname%.

Regards
aGerman

Post Reply