0

This question already has an answer here:

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

marked as duplicate by Jeff Schaller, Stephen Harris, Rui F Ribeiro linux Feb 17 at 7:18

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Can it be? Yes. Should it be? No - see Why is looping over find's output bad practice? for example (which also describes some alternatives) – steeldriver Feb 17 at 1:55
  • Why would I care about the "find" command? That's not my focus. – Anonymous Feb 17 at 2:15
  • 1
    The point of "duplicate" isn't to say your question is bad. Indeed, we can keep your question around so that people can find what you asked for, and then be directed to a good answer. Many good questions can have the same answer. We just don't want to duplicate answers. – Stephen Harris Feb 17 at 2:42
  • Oh okay, thanks for clarifying. I didn't really know that exactly, so thanks. – Anonymous Feb 17 at 3:31