I am Merging 2 CSV files coming from 2 Databases (DB). This happens when one CSV is dropped into a directory I am have listening to. Once I get this file I call a web service that calls to BIP to gather the data from the other DB and reads the CSV file I just got in my directory into a final CSV which then lands back into my directory. What I want to do is get the file size of the first file and save it to a variable. Then once I get the 2nd file I want to get its size and save that to a variable. Then I want to compare both variables to verify my final file size is larger than my first file size variable.
I capture the first file size into a Variable called PREsize using this code:
REM -- Get file size of file coming out of DB
for /f "tokens=4 " %%a in ('dir /a-d/-c %FILENAME%.txt ^| findstr /e %FILENAME%.txt') do set PREsize=%%a
Then I get the 2nd file size into variable called POSTsize using this code:
REm ---Check File size
for /f "tokens=4 " %%a in ('dir /a-d/-c %WS_FILENAME% ^| findstr /e %WS_FILENAME%') do set POSTsize=%%a
Then I compare the 2 vars, if POSTsize is smaller I send an email to alert support something is wrong with this code:
REM --- Verify that final file size is larger than first file size
IF %POSTsize% LEQ %PREsize% (GOTO FinalfileFailed)
ECHO File %HOME%\Outbox\myFile.txt is corrupted > Log\Error.log
cscript eMail.vbs "My file merge did not complete. Final CSV file is corrupted."
So this code looks right, but for some reason it doesnt look like the compare is working, at least in my tests I am unable to get the email to occur with the final file size is less than the first file size. Can anyone help.