File compare is writing line before and after

October 9, 2010 at 21:44:25
Specs: Windows XP
When I run the following I get the file before and the file after the missing file. I need to move the unmatched file to a different folder but this would move valid files as well. Is there a way to only save or write the files that do not have a match?

fc /C /L test1.txt test3.txt > test\error.txt

Contents of error.txt:
Comparing files test1.txt and TEST3.TXT

***** test1.txt
C:\Documents and Settings\083110_0000003.tif
C:\Documents and Settings\083110_0000004.tif
C:\Documents and Settings\083110_0000005.tif
***** TEST3.TXT
C:\Documents and Settings\error\083110_0000003.tif
C:\Documents and Settings\error\083110_0000005.tif
*****


See More: File compare is writing line before and after

Report •


#1
October 10, 2010 at 03:28:46
If I get your drift, what you want is the line[s] which are in one but not the other.

@echo off > newfile & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (one) do (
find "%%a" < two > nul
if errorlevel 1 >> newfile echo.%%a
)
=================================


=====================================
Helping others achieve escape felicity

M2


Report •

#2
October 10, 2010 at 07:32:07
Hi,

That works great!! I do have a question. I seem to get 2 'newfiles' when i run this. I replaced 'newfile' with text33.txt for the following and end up with one with exactly what I want, but also with one that is empty. Since I plan to use the one containing the unmatched image to move out of that directory can I get rid of that empty file or prevent that one from being created?

@echo off > text33.txt & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (test1.txt) do (
find "%%a" < test3.txt > nul
if errorlevel 1 >> test33.txt echo.%%a
)


Report •

#3
October 10, 2010 at 07:51:56
I think you figured it out.

Is this a typo?

"@echo off > text33.txt & setLocal enableDELAYedeXpansion"


=====================================
Helping others achieve escape felicity

M2


Report •
Related Solutions


Ask Question