Preparation before concatenation

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Sebastian42
Posts: 8
Joined: 17 Feb 2017 02:28

Preparation before concatenation

#1 Post by Sebastian42 » 14 May 2019 02:22

I have one hundred and twenty m3u8 files that I want to combine into one. Each (?) individual file will open and play in VLC, so I want to make ONE video file from them.
The files are numbered in the extension, instead of in the filename : *.m3u81, *.m3u82, *.m3u83, *.m3u84 etc It seems to me I first need to move the varying digit out of the extension and into the filename : *1.m3u8, *2.m3u8, *3m3u8, *4.m3u8 before I can concatenate them. Am I right ? and if so, is there a BATCH method (or some other better one), rather than a manual one ?

miskox
Posts: 330
Joined: 28 Jun 2010 03:46

Re: Preparation before concatenation

#2 Post by miskox » 15 May 2019 03:29

If file format allows this then you could use

Code: Select all

copy *.m3u* new_file.m3u
Saso

Sebastian42
Posts: 8
Joined: 17 Feb 2017 02:28

Re: Preparation before concatenation

#3 Post by Sebastian42 » 15 May 2019 05:47

The very thing - thanks so much.

Sebastian42
Posts: 8
Joined: 17 Feb 2017 02:28

Re: Preparation before concatenation

#4 Post by Sebastian42 » 15 May 2019 06:56

Spoke too soon. Not knowing the components, I incorrectly assumed that because there was a result, it was a good result. So I am back to the request for a batch file to convert filename.ext1 to filename1.ext; filename.ext2 to filename2.ext; filename.ext3 to filename3.ext and so on 120 times. Once that is done, I know how to do the concatination/joining/merging.

aGerman
Expert
Posts: 3629
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Preparation before concatenation

#5 Post by aGerman » 15 May 2019 09:43

You could try that loop ...

Code: Select all

for /f "delims=" %%i in ('dir /a-d /b *.m3u8*') do (
  set "name=%%~ni"
  set "ext=%%~xi"
  setlocal EnableDelayedExpansion
  move /y "!name!!ext!" "!name!!ext:~5!.m3u8"
  endlocal
)
... but I'm afraid this will still not be the solution you are after, depending on how you proceed to merge these files.
Also try ...

Code: Select all

for /f "delims=" %%i in ('dir /a-d /b *.m3u8*') do (
  set "name=%%~ni"
  set "ext=%%~xi"
  setlocal EnableDelayedExpansion
  set /a "n=10000+!ext:~5!"
  move /y "!name!!ext!" "!name!!n:~-4!.m3u8"
  endlocal
)
Steffen

Sebastian42
Posts: 8
Joined: 17 Feb 2017 02:28

Re: Preparation before concatenation

#6 Post by Sebastian42 » 15 May 2019 22:17

The first set of commands did EXACTLY what I asked for. However, whereas Movie Maker joins many file types, it wont join m3u8. But that is a different kind of problem from what I came to this forum for. Thank you very much. I will try other joiners.

Else I will need a batch file that replaces ext1 with ext2, 120 times.

And I have that from a previous attempt at this :
copy /b *.m3u8 fullmovie.m3u8

That gives one long playable movie containing the 120 components - problem solved.

aGerman
Expert
Posts: 3629
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Preparation before concatenation

#7 Post by aGerman » 16 May 2019 10:02

What about that:

Code: Select all

for /f "delims=" %%i in ('dir /a-d /b *.m3u8*') do (
  set "name=%%~ni"
  set "ext=%%~xi"
  setlocal EnableDelayedExpansion
  set /a "n=10000+!ext:~5!"
  move /y "!name!!ext!" "!name!!n:~-4!.m3u8"
  endlocal
)

>"fullmovie.m3u8" type nul
for /f "delims=" %%i in ('dir /a-d /b /on *.m3u8') do (
  copy /b "fullmovie.m3u8" + "%%i"
)
Steffen

Sebastian42
Posts: 8
Joined: 17 Feb 2017 02:28

Re: Preparation before concatenation

#8 Post by Sebastian42 » 16 May 2019 13:50

I did need to convert M3U8 so that it would play faultlessly in VLC - and I found that in ONLY Xilisoft Video Converter, so the job is done.

Thank you for yet another another batch file - I understand even less of that than the previous ones, but will keep it handy in the unlikely case such a situation arises again.

Post Reply