That's the kind of Input that I tried to process:
Third token is 014 that I thought should be interpreted as 14. Since a prepended 0 marks it as octal number i tried to get rid of it by catenating 1000 and modulus 1000 afterwards. There is no floating point number in your example and as you probably know batch cannot calculate floating point numbers directly.
Hmm. If line 8 is blank it checks whether or not the 6th till 29th character in line 11 is "NO INFORMATION TO REPORT". That means if neither the number in line 8 nor the string in line 11 was found the file name will be appended to problems.txt.
Ahh, I see what you were trying to do now. For the 'NO INFORMATION TO REPORT' check, I was thinking to just use FIND with an errorlevel check as opposed to a line check.
I had to get something working very quickly as deadlines were approaching, so I basically hacked up your code with what limited understanding I had of how it worked.
I came up with the following working code that I'm using now:
Code: Select all
FOR /F "tokens=4*" %%h in ('dir bat*.rpt /a-d^|findstr /bc:"%currentDate%"') do (
set "num=" &set "noinfo="
for /l %%j in (1 1 7) do set /p "="
set "ln=" &set /p "ln="
if defined ln (
for /f "tokens=1-3" %%j in ("!ln!") do (
IF "%%j"=="Credit" (
for /f "tokens=1,2,3,4 delims= " %%m in ('FINDSTR /C:"Total Approved 0" %%i') DO SET CREDIT=%%p
IF "%%j"=="Debit" (
for /f "tokens=1,2,3,4 delims= " %%m in ('FINDSTR /C:"Total Approved 0" %%i') DO SET DEBIT=%%p
IF NOT "!CREDIT!"=="" IF NOT "!DEBIT!"=="" for /f %%Q in ('S:\SORT\ITWORK\DOSCALC\CALC.EXE !CREDIT!+!DEBIT!') DO (
ECHO D%MM%/%DD%'%YYYY:~2,2%>> IMPORT.QIF
ECHO T-%%Q >> IMPORT.QIF
ECHO L[CC Receivable]>> IMPORT.QIF
for /f "tokens=3" %%j in ("!ln!") do echo PBatch %%j >> IMPORT.QIF
ECHO ^^>> IMPORT.QIF
) else (
FIND "NO INFORMATION TO REPORT" %%i > NUL
IF ERRORLEVEL 1 ECHO NOTEPAD %%i >> PROBLEMS.TXT
%currentDate%, %MM%, %DD%, and %YYYY% are defined earlier as this segment of code was integrated into another batch.
Let me know what you think of my methodology. I'm sure there were much better ways to code various aspects in my 'solution'.