0

I would like to concatenate 3 mp4 videos into one avi video for every folder of a directory, with FFMPEG on Windows 7.

I have started this way:

ffmpeg -f concat -i mylist.txt -c copy E:\EA2014\EX14R\EX14R.avi

with mylist.txt being:

file 'E:\EA2014\EX14R\DCIM\100GOPRO\GOPR0001.MP4' 
file 'E:\EA2014\EX14R\DCIM\100GOPRO\GP010001.MP4' 
file 'E:\EA2014\EX14R\DCIM\100GOPRO\GP020001.MP4' 

This works fine. Now, I would like to automate it because I have lots of those folders full of videos to merge. I tried with this to start with:

printf "file '$s'\n" .E\EA2014\EX14R\DCIM\100GOPRO\*.MP4 >> mylist.txt

But it tells me that

"printf is not recognized as an internal or external command, operable program or batch file"

Is it because I work in Windows? Anyone could help me achieve it in another way?

Needless to say that I am a newbie!

Thanks!

user3406207
  • 315
  • 1
  • 3
  • 18
  • possibly use a scripting language, or, if you're addicted to batch files, http://stackoverflow.com/questions/138497/iterate-all-files-in-a-directory-using-a-for-loop might help – rogerdpack Apr 21 '14 at 16:31
  • Does each folder contain exactly three MP4 files? Where does the target filename come from? Is the target location fixed? – foxidrive Apr 21 '14 at 22:29
  • Each folder contains 3 MP4. Their filename are autogenerated from the camera device (gopro). The target location would change for every folder (eg EX14R, EX15R, EX16R, etc.) – user3406207 Apr 22 '14 at 00:48

1 Answers1

0

This should process each folder under the E:\EA2014\EX14R tree and create the .avi file in each individual folder, calling it myfile.avi

@echo off
for /d /r "E:\EA2014\EX14R" %%a in (*) do (
   if exist "%%a\*.mp4" (
      del mylist.txt 2>nul
      for %%b in ("%%a\*.mp4") do >>mylist.txt echo file '%%b'
      ffmpeg -f concat -i mylist.txt -c copy "%%a\myfile.avi"
      del mylist.txt 2>nul
   )
)
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • Thanks foxidrive. I am getting this error: %%a was unexpected at this time. How do I solve this issue? – user3406207 Apr 22 '14 at 09:01
  • Did you put it in a batch file? Did you change anything? – foxidrive Apr 22 '14 at 16:23
  • I did put it in a batch file. I just changed the second line to : for /d /r "E:\EA2014" %%a in (*) do ( Because the folders containing the mp4 files are all located in EA2014 – user3406207 Apr 23 '14 at 00:02
  • Maybe some editing error crept in - I tested the script here in an elementary way and it didn't generate any errors. Try copy/paste again and put `echo` before the `ffmpeg` and run it as it is. – foxidrive Apr 23 '14 at 03:10