0

How can I run the command below recursively on all directories and sub-directories within?

[someone@someones-pc ~]$ for i in *.mp4; do ffmpeg -i "$i" -i watermark.png -filter_complex "overlay=1623:25" /output/directory/"${i%.*}.mp4"; done

Right now the above command will only search for all .mp4's within the chosen directory and run the command(s) on them, however if I have another directory or deeper sub-directories containing more .mp4's this will not find them. How can I alter this command to run on other .mp4's that are also in other sub-directories and possibly even deeper within?


EDIT: (found this here on stackexchange)

How can this script be edited to work with my FFmpeg command above?

#!/bin/bash

WM=$HOME/public_html/image/catalog/logo-website/watermark.png  # This is the path to your watermark image
SCALE=100                          # This sets the scale % of your watermark image
STARTDIR="/home/whatever/images"   # This is the directory to start in

for imagedir in $( find $STARTDIR -type d )
do
  echo "Running in $imagedir ..."
  cd $imagedir
  file -i * | grep image | awk -F':' '{ print $1 }' | while read IMAGE
  do
    echo "Watermarking $IMAGE"
    composite -dissolve 40% -gravity SouthEast -quality 100 \( $WM -resize $SCALE% \) "$IMAGE" "$IMAGE"
  done
done
Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
Anonymous
  • 503

0 Answers0