Author Topic: EEVblog2 How To Join .MTS AVCHD Video Files  (Read 1922 times)

0 Members and 1 Guest are viewing this topic.

Offline Maalobs

  • Contributor
  • Posts: 16
  • Country: se
EEVblog2 How To Join .MTS AVCHD Video Files
« on: August 05, 2017, 02:06:06 pm »
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.mts

If 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.mts

The 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!
 

Online amyk

  • Super Contributor
  • ***
  • Posts: 6823
Re: EEVblog2 How To Join .MTS AVCHD Video Files
« Reply #1 on: August 05, 2017, 04:50:59 pm »
In my experience with copy /b, it takes the files in directory order, not sorted...
 

Offline boffin

  • Supporter
  • ****
  • Posts: 958
  • Country: ca
Re: EEVblog2 How To Join .MTS AVCHD Video Files
« Reply #2 on: August 06, 2017, 05:20:24 am »
In my experience with copy /b, it takes the files in directory order, not sorted...

Actually Windows/CMD has got a little smarter over the years, it does now sort it first
 

Offline Maalobs

  • Contributor
  • Posts: 16
  • Country: se
Re: EEVblog2 How To Join .MTS AVCHD Video Files
« Reply #3 on: August 06, 2017, 02:51:28 pm »
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.txt

Now type them with a wildcard and see how they come out in alphabetical order:
type ?.txt

Copy them with a wildcard to a merged destination:
copy ?.txt merged.txt

Again see how they came out in alphabetical order:
type merged.txt
 

Offline bw2341

  • Regular Contributor
  • *
  • Posts: 55
  • Country: ca
Re: EEVblog2 How To Join .MTS AVCHD Video Files
« Reply #4 on: August 13, 2017, 08:00:07 pm »
In my experience with copy /b, it takes the files in directory order, not sorted...

Actually Windows/CMD has got a little smarter over the years, it does now sort it first

This is not true. From the semi-authoritative source of Raymond Chen's blog:
https://blogs.msdn.microsoft.com/oldnewthing/20140304-00/?p=1603

It 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.txt
for /l %i in (0,1,4) do @echo %i > %i.txt


The files are out of order on the disk:
D:\outOForder>dir /b
5.txt
6.txt
7.txt
8.txt
9.txt
0.txt
1.txt
2.txt
3.txt
4.txt


Using copy + will copy them out of order:
D:\outOForder>copy ?.txt merged.txt
5.txt
6.txt
7.txt
8.txt
9.txt
0.txt
1.txt
2.txt
3.txt
4.txt
        1 file(s) copied.


The resulting merged file will be out of order:
D:\outOForder>type merged.txt
5
6
7
8
9
0
1
2
3
4


I 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.txt

D:\outOForder>type mergedGOOD.txt
0
1
2
3
4
5
6
7
8
9


The usebackq setting enables the use of the dir ?.txt /b /on command to generate a sorted list of files.
I am wary of claiming this as a definitive solution since the type command 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 like copy /b +.

If I had to do this type of operation myself, I would use dir /b /on to create an ordered list of files and use Notepad to compose the copy /b + command.
 
The following users thanked this post: drussell


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf