Search code examples
bashcsvdirectorymp4ffprobe

FFprobe to recursively search files to output to csv


I am trying to run a bash script but am encountering some errors.

I want to recursively make the command search through the folder and look for all mp4 files. Then i want it to run the ffprobe command and output it to a csv file in a different location with the filename of the mp4 it ran with .csv

So far i have this

#!/bin/bash

for file in /this/is/directory1/*.mp4; do
    ffprobe -show_packets -of csv=print_section=0 $file >> /this/is/directory2/${file}.csv

done

Solution

  • Try this:

    find . -type f -name "*.mp4" | xargs -I{} bash -c "ffprobe -show_packets -of csv=print_section=0 {} > /tmp/\$(basename {} | cut -d. -f1).csv"
    

    OR without using xargs

    find . -type f -name "*.mp4" -exec bash -c "ffprobe -show_packets -of csv=print_section=0 {} > /tmp/\$(basename {} | cut -d. -f1).csv" ';'
    

    Change the path of directory output file in the command above.