I like @Customer’s suggestion of directory sorting, so I tried that:
dir /b /od /s *.mp4 > list.txt
Unfortunately, that didn’t quite give me the results that I wanted, because my output ended up looking like this:
T:\record\20240423\00\00.mp4
T:\record\20240423\00\01.mp4
T:\record\20240423\00\02.mp4
⋮
T:\record\20240505\20\15.mp4
T:\record\20240505\20\16.mp4
T:\record\20240505\20\17.mp4
T:\record\20240418\07\38.mp4
T:\record\20240418\07\39.mp4
T:\record\20240418\07\40.mp4
⋮
T:\record\20240422\23\57.mp4
T:\record\20240422\23\58.mp4
T:\record\20240422\23\59.mp4
This also happened when I used the /on
switch for my dir
command.
Since I was still on the command line, I just did this:
sort list.txt /o list_sorted.txt
That fixed the file order issue, so I might as well do it all with a single command, using a pipe:
dir /b /s *.mp4 | sort /o list.txt
Then instead of opening the sorted file in a text editor and doing two different find/replace operations, we can just stay on the command line and take care of it here:
for /f %r in (list.txt) do echo file '%r' >> FFlist.txt
Note that we changed the final output file name here to FFlist.txt
for the FFmpeg format we’re going to use, but at this point we might as well just modify our command and do it all at once with the original file name:
for /f %r in ('dir /b /s *.mp4 ^| sort') do echo file '%r' >> file.txt
That at least gets us to the point where we pass the work off to FFmpeg, but I haven’t yet taken the time to muck about with that in Windows. (My limited experience with it so far has been on Linux, and in that instance I had to change the audio encoding to make it work.)
There are probably better and/or faster ways to do it (maybe PowerShell has some cool tool that makes it even easier; I haven’t ever taken the time to learn PowerShell), but I like trying to make friends with the regular ol’ DOS-like command line and use its built-in tools to make life easier. Of course, if this is something I intended to do on a regular basis, I’d just write a script or batch file to do everything in one go.