Computing.Net > Forums > Windows XP > Compare two different text files+batch

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Compare two different text files+batch

Reply to Message Icon

Name: dum2010
Date: September 30, 2009 at 00:38:58 Pacific
OS: Windows XP
Subcategory: General
Comment:

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.txt

If the string wasn't found do some action.
How can I do this?
Thanks in advance!



Sponsored Link
Ads by Google

Response Number 1
Name: Sen Hu
Date: October 4, 2009 at 09:55:13 Pacific
Reply:


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



0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Compare two different text files+batch

Excel Comparing two Columns www.computing.net/answers/windows-xp/excel-comparing-two-columns/176769.html

Batch file to edit text file www.computing.net/answers/windows-xp/batch-file-to-edit-text-file/156973.html

Batch File Parsing a text file www.computing.net/answers/windows-xp/batch-file-parsing-a-text-file-/151425.html