EEVblog2 How To Join .MTS AVCHD Video Files - Page 1
Forum section: electronics / general

author: Maalobs
author_rank: Contributor
timestamp: August 05, 2017, 02:06:06 pm
content: Hi Dave,Just wanted to give you a quick tip on merging those MTS-files together in the future.There is no need to put together that long and cumbersome command line with:copy /b 00000.mts + 00001.mts + [...] e:\Merged.mtsIf you maintain the same method that you have now with a unique folder where only the relevant source MTS-files are located, then all that you need to run is this:copy /b *.mts e:\Merged.mtsThe copy command will process all the files in alphabetical order for you, and it doesn't matter how many source files you have either, they will all be concatenated into the final filename on the command line in the correct order.Hope that helps!

author: amyk
author_rank: Super Contributor
timestamp: August 05, 2017, 04:50:59 pm
content: In my experience with copy /b, it takes the files in directory order, not sorted...

author: boffin
author_rank: Unknown
timestamp: August 06, 2017, 05:20:24 am
content: Quote from: amyk on August 05, 2017, 04:50:59 pmActually Windows/CMD has got a little smarter over the years, it does now sort it first

author: Maalobs
author_rank: Contributor
timestamp: August 06, 2017, 02:51:28 pm
content: Yes, the wildcard is expanded to alphabetical sorting, which can be easily tested with a simple experiment.Create ten files named "0.txt" to "9.txt" with the digit in the filename as content:for /l %i in (0,1,9) do @echo %i > %i.txtNow type them with a wildcard and see how they come out in alphabetical order:type ?.txtCopy them with a wildcard to a merged destination:copy ?.txt merged.txtAgain see how they came out in alphabetical order:type merged.txt

author: bw2341
author_rank: Regular Contributor
timestamp: August 13, 2017, 08:00:07 pm
content: Quote from: boffin on August 06, 2017, 05:20:24 amThis is not true. From the semi-authoritative source of Raymond Chen's blog:https://blogs.msdn.microsoft.com/oldnewthing/20140304-00/?p=1603It depends on the filesystem in use. On NTFS, it will effectively sort alphabetically but you shouldn't rely on this behaviour. Cameras usually use FAT32 or exFAT where the files will be in the order they are created. If you always shoot in order, never delete on the camera and always reformat after transferring, the files will be order. If you do delete on the camera, the old empty directory entry might be filled first with the newest file which will put the files out of order.Here's my test on FAT32 and exFAT using Maalobs's example but creating the files out of order:for /l %i in (5,1,9) do @echo %i > %i.txtfor /l %i in (0,1,4) do @echo %i > %i.txtThe files are out of order on the disk:D:\outOForder>dir /b5.txt6.txt7.txt8.txt9.txt0.txt1.txt2.txt3.txt4.txtUsingcopy +will copy them out of order:D:\outOForder>copy ?.txt merged.txt5.txt6.txt7.txt8.txt9.txt0.txt1.txt2.txt3.txt4.txt1 file(s) copied.The resulting merged file will be out of order:D:\outOForder>type merged.txt5678901234I haven't written batch files for a long time but here is an alternate solution that seems to work:FOR /F "usebackq" %i IN (`dir ?.txt /b /on`) DO type %i >> mergedGOOD.txtD:\outOForder>type mergedGOOD.txt0123456789Theusebackqsetting enables the use of thedir ?.txt /b /oncommand to generate a sorted list of files.I am wary of claiming this as a definitive solution since thetypecommand seems to be used for encoding conversion and other things that might ruin binary files. I made a cursory test with two binary files and it seemed to work just likecopy /b +.If I had to do this type of operation myself, I would usedir /b /onto create an ordered list of files and use Notepad to compose thecopy /b +command.