Compare by content: Possible to ignore first n lines?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Asperamanca
Junior Member
Junior Member
Posts: 22
Joined: 2005-03-28, 12:50 UTC

Compare by content: Possible to ignore first n lines?

Post by *Asperamanca »

I have a case where I need to compare two deep folder trees. Problem is that all files include a header, where a date and version number of the files is updated via script. If I compare by content, all files are marked as different, because this date and version number has been changed.
However, I'd like to know which files actually have different content apart from that header.

Is there any way, e.g. telling the sync tool to ignore the first n lines in each file?
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

You can't tell TC to do that, you only can use custom comparer plugin that will ignore first lines...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You can use file "filesys" content plugin as a starting point, it has a text compare function "ContentCompareFiles". All you need to do is skip the first X lines per file.
Author of Total Commander
https://www.ghisler.com
JacobK
Junior Member
Junior Member
Posts: 3
Joined: 2018-04-21, 00:11 UTC

result "less" and "greater"?

Post by *JacobK »

Is it possible, in content plugin from ContentCompareFiles, to return result "less" and "greater"?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

No, because the sync tool does not distinguish between larger/smaller files when selecting them. It only sets options equal, not equal, equal if text, left newer, right newer.
Author of Total Commander
https://www.ghisler.com
JacobK
Junior Member
Junior Member
Posts: 3
Joined: 2018-04-21, 00:11 UTC

Post by *JacobK »

Thank you, Christian.

OK, how can I return "left newer", "right newer"?
In contentpluginhelp2.10se.zip/contentplugin.HLP it lists:
1 The two files are equal, show equal sign in list
2 The two files are equal, show equal sign with 'TXT' below it in lists:
0 The two files are different
-1 Could not open at least one of the files
-2 Compare aborted
-3 The file cannot be compared with this function, please continue with the next plugin...
100 or higher The two files are equal. The plugin file contains a 16x16 icon resource with this numeric ID...
No option for "left newer", "right newer" is mentioned...
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

2JacobK
What do you want to achieve? TC's sync tool already compares file dates without comparison by contents (let alone by contents via content plugins).

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
JacobK
Junior Member
Junior Member
Posts: 3
Joined: 2018-04-21, 00:11 UTC

Post by *JacobK »

I want to create compare plugin which may include custom criteria, not limited to last modification date-time, or even any date-time, and return not only '==' and '!=' results, but also '>' and '<'.
Thank you,
Jacob
gurtang
Junior Member
Junior Member
Posts: 4
Joined: 2022-06-08, 15:23 UTC

Re:

Post by *gurtang »

MVV wrote: 2017-10-13, 10:47 UTC You can't tell TC to do that, you only can use custom comparer plugin that will ignore first lines...
Hi. Can you help me how to do it?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Re:

Post by *Horst.Epp »

gurtang wrote: 2022-06-08, 15:30 UTC
MVV wrote: 2017-10-13, 10:47 UTC You can't tell TC to do that, you only can use custom comparer plugin that will ignore first lines...
Hi. Can you help me how to do it?
Find a compare tool with this function and create a button in TC for it
using %c1 %c2 as parameter.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
gurtang
Junior Member
Junior Member
Posts: 4
Joined: 2022-06-08, 15:23 UTC

Re: Re:

Post by *gurtang »

Horst.Epp wrote: 2022-06-08, 15:55 UTC
gurtang wrote: 2022-06-08, 15:30 UTC
MVV wrote: 2017-10-13, 10:47 UTC You can't tell TC to do that, you only can use custom comparer plugin that will ignore first lines...
Hi. Can you help me how to do it?
Find a compare tool with this function and create a button in TC for it
using %c1 %c2 as parameter.
I am sorry, but where to find compare tool?
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Re:

Post by *Horst.Epp »

gurtang wrote: 2022-06-08, 16:01 UTC
Horst.Epp wrote: 2022-06-08, 15:55 UTC
gurtang wrote: 2022-06-08, 15:30 UTC

Hi. Can you help me how to do it?
Find a compare tool with this function and create a button in TC for it
using %c1 %c2 as parameter.
I am sorry, but where to find compare tool?
Google for it and you may found Beyond Compare for example.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Compare by content: Possible to ignore first n lines?

Post by *tuska »

WinMerge
WinMerge is an Open Source differencing and merging tool for Windows.
WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
WinMerge Help -> Command line
/l linenumber -> Specifies a line number to jump to after loading the files.
/c charpos      -> Specifies a character position to jump to after loading the files.

Example:
Mark the files to be compared, then press the button -> see: Button (CODE).
Button with command: Path\to\WinMergeU.exe /l 5 ... opens WinMerge and positions the cursor in the 5th line ...
The following setting in WinMerge is overridden, i.e. this setting is no longer valid:
Menu "Edit" -> "Options" -> General: Automatically scroll to first difference.
In this case, the button "Next Difference (Alt+Down)" must be pressed.
Button (CODE)
Path to WinMergeU.exe must be adjusted!

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Tools\WinMergePortableZip\WinMergeU.exe /l 5
%c1 %c2
%COMMANDER_PATH%\Tools\WinMergePortableZip\WinMergeU.exe
%COMMANDER_PATH%\Tools\WinMergePortableZip\WinMergeU.exe /l 5|WinMergePortable 2.16.20 x64 (Compare files/folders)|https://ghisler.ch/board/viewtopic.php?t=48634|Compare by content: Possible to ignore first n lines?|WinMerge https://winmerge.org/?lang=en


-1
Create a Button in the Buttonbar (copy/paste CODE)
  1. Click on "SELECT ALL" (to the right of CODE:), then press CTRL+C (copy to clipboard).
  2. Right-click on any place in the button bar, then click on "Paste".
     ⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺
  3. Option1: Point to the new button (slightly longer): 'Tooltip' is shown (-> description to the button).
                  A maximum of 259 characters is allowed for the tooltip. | = create line break, || = create | as separator character.
  4. Option2: Button bar - "Tooltip" field: A single space deactivates the display of the tooltip.
                  If the "Tooltip" field is empty, the content of the "Command" field is displayed.
  5. Option3: See FAQs and explanation: Button-code (TOTALCMD#BAR#DATA)  <-- <Ctrl+click on the link...>
Note:
wincmd.ini -> section [Configuration]

Code: Select all

CompareTool=Path\to\WinMergeU.exe ... (e.g. %COMMANDER_PATH%\Tools\WinMergePortableZip\WinMergeU.exe)
-AND-
Button with command: cm_CompareFilesByContent
causes that instead of the internal comparison tool of Total Commander (cm_IntCompareFilesByContent)
the comparison tool WinMerge (cm_CompareFilesByContent) can be used in Total Commander.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Compare by content: Possible to ignore first n lines?

Post by *Horst.Epp »

2tuska
The WinMerge command line switch /l doesn't do what the poster wants.
It only positions the cursor on the line number in the GUI
but doesn't ignore lines from the comparision.
The only tool I found so far which such a function is Beyond Compare which is not free.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Compare by content: Possible to ignore first n lines?

Post by *tuska »

Horst.Epp wrote: 2022-06-08, 17:40 UTC 2tuska
The WinMerge command line switch /l doesn't do what the poster wants.
It only positions the cursor on the line number in the GUI
but doesn't ignore lines from the comparision.
The only tool I found so far which such a function is Beyond Compare which is not free.
Thank you for pointing this out.
Unfortunately, I misunderstood. :oops:
Post Reply