Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Script text compare, match, text manipulation, append data

60 views
Skip to first unread message

Edulin

unread,
Sep 5, 2012, 11:36:12 AM9/5/12
to
Hi, I need some help to create a script:

Let's assume:

File1
\\server2\share1,\\serverdfs\dfs\test2
\\server1\anothershare,\\serverdfs\dfs\test1
File2
\\server1\share1,/fs7/server1/share1
\\server2\anothershare,/fs1/serverx/share1

Do you know a way to compare matches and present the information in a way like this:
the first field would contains data that would match (non-case sensitive) between the two files and would append the second field of the second file,

\\server2\share1,\\serverdfs\dfs\test2,/fs7/server1/share1
\\server1\anothershare,\\serverdfs\dfs\test1,/fs1/serverx/share1



foxidrive

unread,
Sep 5, 2012, 11:57:20 AM9/5/12
to
You don't specify what is matching. Trying to figure it out from a simple example is a recipe for failure.



--
Mic

edua...@gmail.com

unread,
Sep 5, 2012, 12:27:45 PM9/5/12
to
I'm sorry the first field is the one I'm intrested in which would be the unc path of a share.

\\server2\share1
\\server2\anothershare
or any other like that

I say first field because they are separated by a comma.

foxidrive

unread,
Sep 5, 2012, 12:37:21 PM9/5/12
to
It's still unclear to me.
Are you matching \\server2\ or the entire first field?

How much help do you need BTW, what code have you written so far? :)



--
Mic

edua...@gmail.com

unread,
Sep 5, 2012, 12:47:48 PM9/5/12
to
The entire first field, it could be anything before the first comma,
A lot of help, I have tried to figure out this with Gawk but it's not
working.

billious

unread,
Sep 5, 2012, 1:27:15 PM9/5/12
to
The problem is the data you originally presented:

File1
\\server2\share1,\\serverdfs\dfs\test2
\\server1\anothershare,\\serverdfs\dfs\test1
File2
\\server1\share1,/fs7/server1/share1
\\server2\anothershare,/fs1/serverx/share1


In file1, the first field of the first line is "\\server2\share1" which
does NOT match the first token on the first line in File2,
"\\server1\share1"

That's why showing real data is preferred - censored to remove
identifying information like email addresses if required.

Now assuming that the first file is to be matched against
File2
\\server2\share1,/fs7/server1/share1
\\server1\anothershare,/fs1/serverx/share1

to produce the output you nominate in file file3 then this should do the
job:

@ECHO OFF
DEL file3 2>nul
FOR /f "tokens=1*delims=," %%i IN (file1.) DO (
FOR /f "tokens=1*delims=," %%a IN (file2.) DO (
IF /i "%%i"=="%%a" >>file3 ECHO %%i,%%j,%%b
)
)


Note: 7 lines. Please cut-and-paste as batch can be sensitive to spacing.

edua...@gmail.com

unread,
Sep 5, 2012, 1:34:06 PM9/5/12
to
On 5 sep, 13:27, billious <billious_1...@hotmail.com> wrote:
Incredible, I didn't realize my mistake until you pointed it out.
And this script you provided worked exactly as I required, I was doing
a findstr /x instead of using IF /i -> didn't know this trick.

It's so simple and so great, I am very thankful, appreciate your help.
0 new messages