Computing.Net > Forums > Programming > Comparing files/ lists with 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.

Comparing files/ lists with batch

Reply to Message Icon

Name: uli_glueck
Date: May 2, 2005 at 06:15:16 Pacific
OS: NT 4
CPU/Ram: PIII
Comment:

Hi,

I want to compare two lists.

In list1.txt are the Pc names where the job is done.

In list2.txt are all pcs where the job must be done.

result.txt should be a list whith the pcs where the job isn´t yet done.

My batch isn´t really working:

FOR /f "skip=2 tokens=1,4*" %%a in ('find "PC" list1.txt') do find "PC" <list2.txt | find/v "%%b" >>result.txt

Lists it as many times a pcs are in list1.txt without the one which is in %%b

...>result.txt
Lists it only without the last PC of list1.txt

tnx in advance for any help
uli



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 3, 2005 at 05:05:18 Pacific
Reply:

Hi,

Try thios:

::**
:: Uses DONE and ALLJOBS to make TODO

@echo off > todo.txt

:main

for /f "tokens=* delims=" %%J in ('type ALLJOBS.TXT') do call :todo-r %%J
goto :eof

:todo-r

find "%1" < DONE.TXT > nul
if errorlevel 1 echo %1 >> TODO.TXT

M2


If at first you don't succeed, you're about average.


0

Response Number 2
Name: Mechanix2Go
Date: May 3, 2005 at 06:31:30 Pacific
Reply:

HOLD ON.

This is not working right on some files.

I'm working on it.

M2


If at first you don't succeed, you're about average.


0

Response Number 3
Name: Mechanix2Go
Date: May 3, 2005 at 07:28:12 Pacific
Reply:

Try this:

::**
:: Uses DONE and ALLJOBS to make TODO
:: The :~0,-1 is needed to get rid of a traling space

@echo off > todo.txt

:main

for /f "tokens=* delims=" %%J in ('type ALLJOBS.TXT') do set line=%%J & call :todo-r
goto :eof

:todo-r

find "%line:~0,-1%" < DONE.TXT > nul
if errorlevel 1 echo %line:~0,-1% >> TODO.TXT
::**


M2


If at first you don't succeed, you're about average.


0

Response Number 4
Name: uli_glueck
Date: May 3, 2005 at 07:44:35 Pacific
Reply:

Thanks a lot M2. That does Job. :-)

uli


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Comparing files/ lists with batch

Making a list with batch www.computing.net/answers/programming/making-a-list-with-batch/15947.html

Batch/script file - compare file na www.computing.net/answers/programming/batchscript-file-compare-file-na/18358.html

Comparing Files+Folders using VBS www.computing.net/answers/programming/comparing-filesfolders-using-vbs/14112.html