Situation:
- Running macOS 10.13.6 and using bash 5.0.17(1)
- A lot of subdirectories which hold multiple files.
- Need to filter out files in subdirectories with a specific extension (.avi).
- Need to process all .avi files and remux to .mp4 using
ffmpeg.ffmpeguses the following syntax for remuxing:ffmpeg -i in.avi -c copy out.mp4 - Output format: in the same folder as the source .avi file, and using the same filename (apart from the .avi extension)
Example file structure:
$ find . -maxdepth 2
.
./abc
./abc/abc.avi
./xyz
./xyz/xyz.avi.mp4
./123
./123/123.avi
In this case I would like to filter out the files ./abc/abc.avi and ./123/123.avi , which I can do using regular expressions and find:
$ find -E . -iregex ".*\.avi"
./abc/abc.avi
./123/123.avi
The desired remuxed .mp4 output filenames would then be:
./abc/abc.mp4
./123/123.mp4
How can I:
- using a script, remux all these
.avifiles to.mp4container with one command? I am not sure how to pipe the output offindto the input offfmpeg, and at the same time specify the desired output filenames. - delete the original
.avifiles, but only if the remux was successful?