In which order are files passed to a script when I click them?

General discussion related to "Everything".
Post Reply
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

In which order are files passed to a script when I click them?

Post by Native2904 »

I create a script (with help of AI) that analyzes duplicate music files with ffmpeg and generates a spectrogram for each file.
So far so good..
I then compare these spectrograms using WinMerge, or visually by overlaying them into a single image and viewing the result in an image viewer.

I tried adding the file names onto the images using the “drawtext” command, but since many of my music files contain special characters and spaces, the script doesn’t work reliably. So this approach isn’t a viable option for identifying the spectrograms by title.

I just need to know whether the click order determines the order in which files are passed to the script.
For example, if I click track A and then track B, will track A be passed to the script first?
Logically, one would assume that track A is passed first, but this seemingly has no effect on how the files are actually passed.
Last edited by Native2904 on Wed Apr 08, 2026 5:48 pm, edited 1 time in total.
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: In which order are files passed to a script when I click them?

Post by therube »

Might depend on how you're passing?
From command-line, might differ from SendTo, might differ from...


In general, I'm thinking files will be passed in sort order.


In your bath file, you can do something like, ECHO %*, & that should show you the order the file names were passed (which again, might be different on how they are interpreted).


There are times when "click" (actually, an "open") does come into play.
That I've only noticed when dealing with files that are both in a sandbox (Sandboxie) & also outside of the sandbox.

1. c:/xyz.txt
2. c:/sandboxie/xyz.txt

If I click 1 2 & send those two files to WinMerge
I'll get different "opens" then if I click 2 1 & send those to WinMerge

In one case WinMerge will open normally, & in the other case, WinMerge will open running Sandbox'd.


There might also be the case that the program you're sending the files to will sort them in a different order then you sent them. (Don't really recall, but some Windows programs are that way... unless you specifically, can't remember, do "something", in which case said program will read the inputs in the order received.)
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: In which order are files passed to a script when I click them?

Post by therube »

ffmpeg -f concat -safe 0 -i %OUT%\CONCAT3.TXT -c copy %OFILE%


In this case, files to be concatenated are stored in CONCAT3.TXT, & ffmpeg reads that file sequentially.
So if part1 part2 par3, you end up with 123
And if part3 part1 part2, you end up with 312

ffmpeg -i %1 -i %2 -acodec copy -vcodec copy "C:\OUT\%BASENAME%" 2>&1 | tee "C:\OUT\%BASENAME%.TXT"


This is a CONCAT, & ordering is immaterial.
It simply takes two file names & concatenates them.

ffmpeg -i %VIDEO% -i %AUDIO% -c copy -map 0:v:0 -map 1:a:0 -bsf:a aac_adtstoasc "%OFILE%" 2>&1 | tee -a %LOG%


This is what I call a MUX (though it is really a JOIN).
And in this case, ordering must be; video file, audio file.
So in Everything, I make sure sort order is as needed such that 1. video, followed by 2. audio.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: In which order are files passed to a script when I click them?

Post by Native2904 »

Sorry, I forgot to mention – there are two files from Everything.
Last edited by Native2904 on Wed Apr 08, 2026 5:48 pm, edited 1 time in total.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: In which order are files passed to a script when I click them?

Post by Native2904 »

2 therube
Hi,
thank you for your response..

The command look like this:

Code: Select all

@echo off
setlocal EnableExtensions EnableDelayedExpansion

set "file1=%~1"
set "file2=%~2"

"%ffmpeg%" -y -i "%file1%" ^
-filter_complex "[0:a]aformat=channel_layouts=mono,showspectrumpic=s=2048x800:legend=1:scale=log,drawtext=text='1':x=20:y=20:fontsize=60:fontcolor=white:borderw=2" ^
-frames:v 1 "%out1%"
 
...
The script also writes a log file, which I check as well:

Code: Select all

======================================== 
Start: 08.04.2026 16:48:27,08 
Datei1: Z:\Musik\KuschelRock 1-37\KuschelRock 18 (2004)\CD2\12 - Mad World.mp3 
Datei2: Z:\Musik\Tears.For.Fears.-.This.Is.Tears.For.Fears.2024.MP3.320.Kbps\12 - Mad World.mp3 
======================================== 
 
Fertig: 08.04.2026 16:48:59,87 
======================================== 
but wouldn’t it be more convenient to know directly which file is file 1 or 2?
ffmpeg -f concat -safe 0 -i %OUT%\CONCAT3.TXT -c copy %OFILE%


In this case, files to be concatenated are stored in CONCAT3.TXT, & ffmpeg reads that file sequentially.
So if part1 part2 par3, you end up with 123
And if part3 part1 part2, you end up with 312
So I have to send the files I selected in Everything to CONCAT3.TXT before passing them to ffmpeg?
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: In which order are files passed to a script when I click them?

Post by therube »

Still not too clear.
You select 2 file in Everything, & then... SendTo Spectrogramm, or SendTo mybatch.bat, which runs ffmpeg, then calls Spectrogramm on the ffmpeg outputs? (Has to be the latter, no?)

So if you (in your .bat file)

Code: Select all

@echo off
set "file1=%~1"
set "file2=%~2"
echo file1: %file1%
echo file2: %file2%
pause
you'll know what your %1 & %2 are, how they've been received by the batch file

so if you send CD2, then Tears (if sorted by path), & %1 is CD2 & %2 is Tears,
then if you (sort by path, reverse), you'd expect %1 to be Tears & %2 to be CD2

& then in your log, do Datei1: & Datei2: change, correspondingly?


(Might interest you:
hashmedia.bat
MEDIAINFO_COMPARE.BAT)
therube
Posts: 5711
Joined: Thu Sep 03, 2009 6:48 pm

Re: In which order are files passed to a script when I click them?

Post by therube »

So I have to send the files I selected in Everything to CONCAT3.TXT before passing them to ffmpeg?
I was just giving examples...

For my CONCAT.bat, I select files, send the names to a file, finagle it a bit.
Then ffmpeg reads that file & concat's them.
So the order that the file names end up in CONCAT3.TXT is the order that ffmpeg concat's them.

In my other examples, in 1 case ordering doesn't matter, in the other case it does.
For the latter, i have to pass the video filename before the audio filename. So %1 & %2 need to be such that %1 is the video file & %2 is the audio file.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: In which order are files passed to a script when I click them?

Post by Native2904 »

SendTo Spectrogramm, or SendTo mybatch.bat

Code: Select all

"🎜 Vgl. Audio - Spectrogramm -Viewer"	"diff: audio view:VIV"	"false"	"true"	"*.mp3;*.flac"	"C:\Everything\Tools\Scripte\Spectrogramm2.bat "%*" "
about a bat file.
I have checked — legally, the order in which I click the files is always the same, so I don’t know which parameter determines which file gets passed first.
Diff_audio12.gif
Diff_audio12.gif (1.48 MiB) Viewed 1337 times
These files aren’t actually duplicates; they just have the same name and are only used as an example.

I'm using a long time your MEDIAINFO_COMPARE.BAT but with TC..thank you therefor
Last edited by Native2904 on Thu Apr 09, 2026 6:41 am, edited 1 time in total.
void
Developer
Posts: 19830
Joined: Fri Oct 16, 2009 11:31 pm

Re: In which order are files passed to a script when I click them?

Post by void »

For custom_open_commands and %*, the order is the selection as shown in Everything.
So it will depend on your sort order.



To change the order to focus first, enable Tools -> Options -> Advanced -> selection_focus_first
The order is then: The focused selection, then the selection after the focus as shown, then the selection before the focus as shown.
If the focus is not selected, then the selection as shown.
Native2904
Posts: 112
Joined: Mon Nov 22, 2021 8:36 pm

Re: In which order are files passed to a script when I click them?

Post by Native2904 »

Thanks, that’s easy to remember – from top to bottom...
Post Reply