0

I have two file types with the same filenames in one directory:

file1.ts
file1.ec3
file2.ts
file2.ec3

and I need to make a loop which would process pair of files at once (file1.ts + file1.ec3). Then the loop needs to be restarted with second pair (file2.ts + file2.ec3).

Here is my code:

for i in *.ts; do
    for e in *.ec3; do
        ffmpeg -i "$i" -i "$e" -map 0:v -map 1:a -codec copy "${i%.ts}_DD+.ts";
    done;
done

But when the first cycle ends it tries to process file1.ts + file2.ec3 and brakes everything...

How can I make it work properly?

1 Answer 1

3

Try this:

for file in *.ts; do
    [ -f "${file%.ts}.ec3" ] &&
        ffmpeg -i "$file" -i "${file%.ts}.ec3" -map 0:v -map 1:a \
            -codec copy "${file%.ts}_DD+.ts"
done
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.