I wrote a simple bash script to convert video files. When run, it first makes output
directory and then iterates over all .mp4
files, converts them and puts the result to output
directory.
mkdir output && for f in *.mp4; do echo $f; \
ffmpeg -loglevel warning -i $f -vf scale=1280:-2,fps=25 output/$f; done
I'd like to add to the script one feature: looping in all the sub-directories (but no the current directory itself), creating 'output` directory and executing conversion.
I managed to find all files meeting given criterion in all sub-directories by using this code:
for d in */; do
for f in "$d"/*.mp4; do
echo "$d"
file="${f##*/}"
echo "$file"
done
done
The script prints the following, which is correct.
1/
01.mp4
2/
02.mp4
However, that's all I was able to do.
You can use find to search directories recursively.
Or a for loop with globstar: