MEDIAINFO_COMPARE.BAT

Off-topic posts of interest to the "Everything" community.
Post Reply
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

MEDIAINFO_COMPARE.BAT

Post by therube »

MEDIAINFO_COMPARE.BAT
MI_COMPARE.BAT

Displays "media information" of audio, video files.
Can display/compare 1 or 2 or 3 files' data.

Way, way, way back, I was good with dealing with pairs of files.
Then I up'd it to handle 3 files...

For 2, (Altap Salamander's) Compare worked fine. (Salamander required & must be running).
For 3, WinMerge can handle 3 (or 2).

Salamander's Compare & WinMerge display, differently.
And one can replace either with their own "compare"...
And you can set up a hotkey in Everything to compare sets of files.

MI_COMPARE.bat:

Code: Select all

:: MediaInfo _ command_com line COMPARATOR with CALL to Salamander's File Comparator
::                                              or, if 3 files passed, use WinMerge   SjB 10-30-2024

@echo	off


:: check for 3 files passed, & if 3, then run MI_COMPARE3.bat (WinMerge) instead
if      NOT [%3]==[]   ( 
			 MI_COMPARE3.bat   %*
                         goto :EOF
                       )

:: you do NOT want to use, START "MI3" MI_COMPARE3.BAT... (or cmd /c start), above!
:: doing so, will cause the MI3 window to hang around !



set	X_TEMP_PATH=%PATH%
path	%PATH%;C:\DEV\CODECS\MediaInfo_CL\;


set	OUT1=C:\OUT\MI_COMPARE1.TXT
set	OUT2=C:\OUT\MI_COMPARE2.TXT

echo	FILE 1:  >  %OUT1%
echo	%1  >> %OUT1%
echo.   >> %OUT1%
echo	FILE 2:  >  %OUT2%
echo	%2  >> %OUT2%
echo.   >> %OUT2%


:: originally, the above echo were not there, & if for some reason the MI failed,
::       like from a too long PATH, kind of thing
::    both the files ending up with nothing in them, so they would compare as
::    "equal", & they "were", except it was comparing against "nothing" instead
::    of actually returned valid results of the MI command
:: anyhow, MI does have exit codes; 0=success, 1=failure, but for some reason
::    depending on, not sure, file order (which one "first") or whatever, again
::    valid result may not have been given
:: with the echo's, at the least there will be some diffs to the files, so the
::    compare, while still not of relevant data, at least will "not compare" &
::    so will point out diffs, & then it's like, ah, what's going on here
:: so at least you know something is up, instead of "falsely" being told, oh,
::    your files compare, exactly [wrong]


C:\DEV\CODECS\MediaInfo_CL\MediaInfo_CL.exe  %1  >>  %OUT1%
:: if	errorlevel 1 echo FILE 1: MEDIAINFO DETECTED FAILURE,  %1  >>  %OUT1%
:: set	errorlevel=

C:\DEV\CODECS\MediaInfo_CL\MediaInfo_CL.exe  %2  >>   %OUT2%
if	errorlevel 1 echo FILE 2: MEDIAINFO DETECTED FAILURE,  %2  >>  %OUT2%
:: for some reason, these (TWO) errorlevel checks were not always returning
:: expected results, so i changed to the 'echo' method (above) which "forces"
:: diffs into %OUT_%, so a failure won't compare equally


"C:\WLIB\Altap Salamander 40\plugins\filecomp\fcremote.exe"  %OUT1%   %OUT2%
:: "C:\WLIB\Altap Salamander 304\plugins\filecomp\fcremote.exe"  C:\OUT\MI_COMPARE1.TXT  C:\OUT\MI_COMPARE2.TXT

set	PATH=%X_TEMP_PATH%
set	X_TEMP_PATH=
MI_COMPARE3.bat:

Code: Select all

:: MediaInfo _ command_com line COMPARATOR with CALL to [Salamander's File Comparator] WinMerge

@echo	off
set	X_TEMP_PATH=%PATH%
path	%PATH%;C:\DEV\CODECS\MediaInfo_CL\;


set	OUT1=C:\OUT\MI_COMPARE1.TXT
set	OUT2=C:\OUT\MI_COMPARE2.TXT
set	OUT3=C:\OUT\MI_COMPARE3.TXT

echo	FILE 1:  >  %OUT1%
echo	%1  >> %OUT1%
echo.   >> %OUT1%
echo	FILE 2:  >  %OUT2%
echo	%2  >> %OUT2%
echo.   >> %OUT2%
echo	FILE 3:  >  %OUT3%
echo	%3  >> %OUT3%
echo.   >> %OUT2%


:: originally, the above echo were not there, & if for some reason the MI failed,
::       like from a too long PATH, kind of thing
::    both the files ending up with nothing in them, so they would compare as
::    "equal", & they "were", except it was comparing against "nothing" instead
::    of actually returned valid results of the MI command
:: anyhow, MI does have exit codes; 0=success, 1=failure, but for some reason
::    depending on, not sure, file order (which one "first") or whatever, again
::    valid result may not have been given
:: with the echo's, at the least there will be some diffs to the files, so the
::    compare, while still not of relevant data, at least will "not compare" &
::    so will point out diffs, & then it's like, ah, what's going on here
:: so at least you know something is up, instead of "falsely" being told, oh,
::    your files compare, exactly [wrong]


C:\DEV\CODECS\MediaInfo_CL\MediaInfo_CL.exe  %1  >>  %OUT1%
:: if	errorlevel 1 echo FILE 1: MEDIAINFO DETECTED FAILURE,  %1  >>  %OUT1%
:: set	errorlevel=

C:\DEV\CODECS\MediaInfo_CL\MediaInfo_CL.exe  %2  >>   %OUT2%
if	errorlevel 1 echo FILE 2: MEDIAINFO DETECTED FAILURE,  %2  >>  %OUT2%
:: for some reason, these (TWO) errorlevel checks were not always returning
:: expected results, so i changed to the 'echo' method (above) which "forces"
:: diffs into %OUT_%, so a failure won't compare equally


if      [%3]==[]  goto  doit2:
C:\DEV\CODECS\MediaInfo_CL\MediaInfo_CL.exe  %3  >>   %OUT3%
if	errorlevel 1 echo FILE 3: MEDIAINFO DETECTED FAILURE,  %3  >>  %OUT3%
goto doit:
:: with this _3 can compare either 2 (now, more properly) or 3 files
:: (2, would be via drag_n_drop, and without a "bogus" 3rd entry showing up)
:: and also, with the change to MI_COMPARE, i can interactively select 3 files
:: in Everything, & using *existing* (Everything) shortcut to MI_COMPARE Alt+I
:: that will run _3 instead, so i can now (10-30-2024) do either 2 or 3,
:: directly, instead of having to "manually" drag 3 files into _3.bat :-)


:doit2
start "" "WinMergeU.exe"  %OUT1%   %OUT2%
goto cleanup:



:doit
start "" "WinMergeU.exe"  %OUT1%   %OUT2%   %OUT3%
:: "C:\WLIB\Altap Salamander 304\plugins\filecomp\fcremote.exe"  C:\OUT\MI_COMPARE1.TXT  C:\OUT\MI_COMPARE2.TXT

:cleanup
set	PATH=%X_TEMP_PATH%
set	X_TEMP_PATH=



:: the START itself, PLUS the quotes in, start "" are NECESSARY, to avoid an
:: "extraneous" ("CMD") window from hanging around until WinMerge is closed!
Relies on MediaInfo (command line version) & some comparison program.


.
Salamander:
MI_COMPARE-salamander.png
MI_COMPARE-salamander.png (34.48 KiB) Viewed 15909 times
WinMerge:
MI_COMPARE-winmerge.png
MI_COMPARE-winmerge.png (45.08 KiB) Viewed 15909 times

Oh, in my above batch files, I use a "MediaInfo_CL.exe".
MediaInfo_CL.exe is simply the file, "MediaInfo.exe" found in the command-line version of MediaInfo, MediaInfo_CLI_##.##_Windows_x64.zip, that I simply renamed to "MediaInfo_CL.exe".
James301
Posts: 3
Joined: Sun Sep 07, 2025 4:58 am

Re: MEDIAINFO_COMPARE.BAT

Post by James301 »

Hey ‘TheRube’ if you’re out there this is James301 from the freefilesync forum. I just wanted to let you know that I have it about 95% up and running. It works from the CLI. The only thing left is to integrate it into Salamander. I’d like to make a button or plug-in, dragging the files onto your FANTASTIC MI_COMPARE.BAT file won’t really work for me because the files will be in different directories.
I saw your comments in line 53:
:: with this _3 can compare either 2 (now, more properly) or 3 files
:: (2, would be via drag_n_drop, and without a "bogus" 3rd entry showing up)
:: and also, with the change to MI_COMPARE, i can interactively select 3 files
:: in Everything, & using *existing* (Everything) shortcut to MI_COMPARE Alt+I
:: that will run _3 instead, so i can now (10-30-2024) do either 2 or 3,
:: directly, instead of having to "manually" drag 3 files into _3.bat :-)
[/color]]EDIT:
I cannot find the ‘*existing* (everything) shortcut to MI_COMPARE Alt+l (not sure if it’s a capital i or a lower case L)’
:roll: LOL, I found *everything*. Heh, I knew I had seen it in your post but I could not find it. See what a little sleep can do for you!

[/color]]EDIT:
Did you turn it into a plug-in? Put it in the User menu? Create a new button? What is the Command Line and Parameters to launch it in Salamander?
:?: I'll need to set up *everything*; I don't even know what it is, or what it can do yet.... but a quick Bullet point run down on how YOU integrated/ use these programs, the command line Parameters to run MI_Compare.bat would really be helpful. I need an example on how you did it/do it, so I can build on your success. I think you are doing exactly what I want to do with my audio files (over 179,000 files). I want to find the duplicates, and remove the lower quality files.

BTW, thank you for introducing me to Salamander. Back in the day I had a program similar to this for the Amiga 3000. Heh, those were the days… I ran an old fashioned dial up bulletin board out of my home. You probably don’t even know what that is! It involved a lot of scripting, and html programming. This was all done on the Amiga, so the commands, the command line structure, and syntax were all different then the PC/IBM. This is like a foreign language to me, but I'm getting there.

Ohh, and thank you so much for getting me to actually think again! It’s kind of exciting.

-Jaz
Last edited by James301 on Sun Sep 07, 2025 3:36 pm, edited 2 times in total.
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: MEDIAINFO_COMPARE.BAT

Post by therube »

To get this working "more efficiently" (to be able to setup hotkeys to open MI_COMPARE.BAT - from within Everything), you'll need Everything 1.5 Alpha.

With that...

Tools | Options | Advanced -> custom_open_command03 --> $exec("C:\BIN\MI_COMPARE.BAT" %*)
Tools | Options | Keyboard -> File | Custom Open 3 --> Add, Result List ---> Alt+I

That sets up a hotkey, Alt+I, that should open MI_COMPARE.BAT.

You'll need to change the path to MI_COMPARE.BAT to where ever you have placed it.
You can use any hotkey, that is available & works for you.
You can use any custom open command slot / File Custom Open slot that you want, it needn't be 3, necessarily.
(I used 'I" cause if the I in mediaInfo.)


Before Everything 1.5, I simply had this set up as a SendTo.
I'd typically select a pair of files in Everything (1.4) & SendTo -> MI_COMPARE.BAT.

With Everything 1.5, I set up a hotkey so that I no longer need the SendTo (except when using programs other then Everything).

You might want to start off on the WinMerge end, first. You already have that & it is a bit more straight forward.

(And not to discount Salamander, but) Salamander does need to be running. (I always have it & Everything running.)
fcremote.exe is Salamander's Compare program. In the batch file, you (again) need to adjust any paths to point to where you have Salamander installed. (I typically use atypical locations.)

In Salamander, Plugins (menu item) | Plugins Manager... -> Test All, seems to help (keep things in "check", after an initial startup of Salamander). (If Salamander generates a message instead of giving results, this "Test" alleviates that.)


All of the above should work with any file manager/comparison program assuming you're able to pass a set of files to them.


because the files will be in different directories
That's the beauty of Everything. It isn't limited to, it doesn't limit you to particular directory structures, per se.
I ran an old fashioned dial up bulletin board out of my home. You probably don’t even know what that is!
Real telephones, xmodem, zmodem..., tiny little .mod files, of course I know what that is.


You can tweak as wanted.
Like instead of default MediaInfo output, you wanted "full" output, then add the -full switch.

C:\DEV\CODECS\MediaInfo_CL\MediaInfo_CL.exe %1 -full >> %OUT1%

To compare sets of files other then "media", then skip the MediaInfo parts entirely, & just call the compare itself.

Code: Select all

:: Salamander _ command_com line COMPARATOR with CALL to Salamander's File Comparator

@echo	off
goto    compare:
:: Salamander _ command_com line COMPARATOR with CALL to Salamander's File Comparator

@echo	off
goto    compare:

:compare
"C:\WLIB\Altap Salamander 40\plugins\filecomp\fcremote.exe"  %1   %2
And again, if you didn't want to use Salamander, you could throw WinMerge (or any other compare program in there).
James301
Posts: 3
Joined: Sun Sep 07, 2025 4:58 am

Re: MEDIAINFO_COMPARE.BAT

Post by James301 »

Hey, ‘theRube’, I did not mean to leave you hanging. Thank you for your help! The day you responded, I spent the next 2 days working on my files following your tips. In those two days, I managed to delete, move, and combine over 8,000 files/folders (thanks to your bat file and you introducing me to *Everything*). Updated/checked the metadata in close to 5,000 files. Needless to say, I got burnt out and had to stay away from it for a while. I’m still on ‘break’, but I thought I’d get back to you.

Edit:
I got Salamander to work with FFS, and *everything*, but I’m still trying to get Salamander to work with your bat file using Salamander’s GUI and the two directory windows. I keep getting errors of some sort or another. I’m trying to create a button through the user menu to call up your bat file. I may have to resort to actually looking at the documentation.
I have your BAT file working with Salamander via the GUI/User menu (see what a little sleep can do) ;)

I just looked at the last ‘code’ you sent:
C:\WLIB\Altap Salamander 40\plugins\filecomp\fcremote.exe" %1 %2
I have not tried it yet! What is messing with my head is the path. What is ‘WLIB’? Is that a Windows system path of some sort (Like %temp% )? And I assume you have Salamander in a directory called ‘Altap Salamander 40’? When you say it will compare ‘other files than media’, do you mean the raw hexadecimal, or something like PDFs, text, Excel, etc? LOL, I got to play with it when I get some sleep, maybe tonight!!!!

Ohh, I got a fix for you.
(And not to discount Salamander, but) Salamander does need to be running. (I always have it & Everything running.)
In salamander, go to plugins/plugin manager.
Select ‘file comparator’ and click on configure.
In the general tab at the bottom, check the box for ‘load the plugin on Alt Salamander start’
Close the program and reopen it. Go to the plugins manager again to make sure ‘file comparator’ has a ‘YES’ under loaded.

Now, if you close the program and call up your Bat file, it will work without needing to have Salamander running.

Thanks again;

-Jaz

P.S. I like *everything*

:D
Last edited by James301 on Sun Sep 14, 2025 12:46 am, edited 1 time in total.
Post Reply