Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I need to write batch script which will compare text string "AAA8888,131676,2000-09-23 00:00:00.0,2009-09-23 07:01:45.0 " from 1.txt with
text string like "Critical 09/22/2000 01:28:12 AAA8888_XXXXX Some text " .
Fields to be compared are in BOLD.
I'm doing this by : "for /F " eol=N tokens=4* delims=_ " %%i in (2.txt) DO FIND "%%i" 1.txtIf the string wasn't found do some action.
How can I do this?
Thanks in advance!

Here is a quick script in biterscripting.
# Script CompareVal.txt # Input arguments var str file1 # Path to first file var str file 2 # Path to second file # Read first text file. var str text1 ; cat $file1 > $text1 # Get the string upto the first comma. var str val1 ; stex "]^,^" $text1 > $val1 # Read second text file. var str text2 ; cat $file2 > $text2 # Remove part till third space. stex "^ ^3]" $text2 > null # Extract string upto next _ (undescrore). var str val2 ; stex "]^_^" $text2 > $val2 # Compare val1 and val2. if ($val1==$val2) echo "Values are same - " $val1 else echo "Values are different - " $val1 " - " $val2 endif
Save the script as C:/Scripts/CompareVal.txt, start biterscripting ( download if necessary from http://www.biterscripting.com ), enter the following command.
script "C:/Scripts/CompareVal.txt" file1("C:/somefolder/1.txt") file2("C:/someelse/2.txt")
That's it. Specify files with full paths enclosed in double quotes.Sen

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |