Fraser_Admin
asked on
using fc with batch file
i have 2 text files called existing.txt and new.txt. each holds a program version number.
i want to check these files before copying in a new version (ie. if they are the same no copy is needed). if the version of new < version of existing i don't want to copy in. i only want new versions greater than existing versions.
i created a vbscript file to give me the version which i send the output to a file. but the file contains a blank line, then the version number.
how do i compare these two files within a batch the way i need to?
i want to check these files before copying in a new version (ie. if they are the same no copy is needed). if the version of new < version of existing i don't want to copy in. i only want new versions greater than existing versions.
i created a vbscript file to give me the version which i send the output to a file. but the file contains a blank line, then the version number.
how do i compare these two files within a batch the way i need to?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Replace line 8 with this:
if /i "%oldVer%" EQU"%newVer%" echo Old version is equal to the old version
Check this for more information on the if command:
if /?
if /i "%oldVer%" EQU"%newVer%" echo Old version is equal to the old version
Check this for more information on the if command:
if /?
ASKER
how do i set a return value in batch
if it is equal or if old > new than I want to return 1 otherwise i want to return 0.
i need to be able to access this value in another batch file. i just want to call this as a separate one.
if it is equal or if old > new than I want to return 1 otherwise i want to return 0.
i need to be able to access this value in another batch file. i just want to call this as a separate one.
if /i "%oldVer%" GTR "%newVer%" exit /B 1
exit /B 0
exit /B 0
ASKER
but how do i access that return value in my calling batch.
ASKER
also, when i call
exit /B 1
for example, i can't see to get past that in my calling batch. i put in some echos after that and nothing appears.
i need to be able to get that value of 1 in my calling batch. i think i can do this with errorlevel right?
exit /B 1
for example, i can't see to get past that in my calling batch. i put in some echos after that and nothing appears.
i need to be able to get that value of 1 in my calling batch. i think i can do this with errorlevel right?
That's right. You answered your own question. Once the batch processing hits a exit, the batch is exited as the command says. You'd test %errorlevel% in your calling batch processing to determine the results.
ASKER
i can't seem to get passed my call to the batch. i put in an echo as soon as i exit from the batch but it does not come up.
I have this in my called batch
exit /B 1
then in the calling batch right after i have the call to this batch i have echo done and it doesn't get there. it is like that exit call is telling it to exit from the called and calling batches.
I have this in my called batch
exit /B 1
then in the calling batch right after i have the call to this batch i have echo done and it doesn't get there. it is like that exit call is telling it to exit from the called and calling batches.
Are you calling the batch file using call?
call yourbatch.bat
If not you won't return.
call yourbatch.bat
If not you won't return.
ASKER
no just figured that out. thanks so much for your help!!!
ASKER
Excellent Response!!
ASKER
1.1.3 or something like that.
how do i compare if they are equal?