a thoughtful web.
Good ideas and conversation. No ads, no tracking.   Login or Take a Tour!
comment
user-inactivated  ·  1558 days ago  ·  link  ·    ·  parent  ·  post: Why is my bash loop not working?

Are you sure ffmpeg was finished before your deleted its input? It sounds like it was just taking longer than you expected.

If that's not it, I don't know. The script doesn't look obviously wrong to me, but you're complicating this more than you need to, and simplifying is often an easier way to fix bugs than figuring out why the complicated thing isn't working. For looping over files in the current directory you want for and a glob:

    for d in */

do

...

done

will loop over just the subdirectories of the current directory. */ only matches directories, so you don't need the test.

Using a subshell to reset the current working directory is going around the world. pushd/popd are what you want. Try

    for d in */

do

pushd "$d"

ffmpeg -f concat -i mylist.txt -threads 35 -c copy concat.avi

popd

done

Since you're not doing set -e you don't need to worry about ffmpeg failing and leaving you in the last directory the script was working on when it failed.