So, I was doing this:

ffmpeg -i /media/johann/5461-000B/DCIM/100MEDIA/IMAG0079.AVI -ss 00:00:00 -t 00:00:20 ~/Public/240321/240321_0079.avi ; rm /media/johann/5461-000B/DCIM/100MEDIA/IMAG0079.AVI

one at a time changing the IMAG0079 to IMAG0080 etc every time. I am sure there must be a way to perform two actions (ffmpg) and (rm) on each file in a folder. Can anyone help (For next time)

Thanks!

  • 12510198
    link
    fedilink
    English
    arrow-up
    14
    ·
    9 months ago

    What about something like this:

    for i in /media/johann/5461-000B/DCIM/100MEDIA/*.AVI; do newpath="$HOME/Public/240321/$(basename "$i" | sed 's/^IMAG/240321_/g')"; ffmpeg -i "$i" -ss 00:00:00 -t 00:00:20 "$newpath" && rm "$i"; done
    
    • johsny@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      9 months ago

      Awesome! Thanks, I knew there had to be a way!

      edit: This also works: for i in *.avi; do ffmpeg -i "$i" -ss 00:00:00 -t 00:00:10 ~/Public/test/${i%.*}.avi ; done

      But yours is much nicer.

        • johsny@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          3
          ·
          9 months ago

          Almost, here is the one that worked: for i in *.avi; do ffmpeg -i "$i" -ss 00:00:00 -t 00:00:10 ~/Public/test/${i%.*}.avi ; done

          Thanks for pointing me in the right direction.