Bash script to create CSV file of all media in a folder (recursively)

The content below is taken from the original ( Bash script to create CSV file of all media in a folder (recursively)), to continue reading please visit the site. Remember to respect the Author & Copyright.

Realizing that some of my media (mostly older files) are in unacceptably poor quality, I was looking for something to scan my media to find said files, so I could know what to attempt to replace going forward. Couldn’t find anything, so I rolled my own. Thought it might be useful to some.

Save script as mi2csv, or whatever you want, in your executable path, and make it executable chmod +x mi2csv

Requires mediainfo to be installed. sudo apt install mediainfo or whatever similar on your system.

Usage:

mi2csv "/path/to/media" "mycsvfile.csv"

Will scan provided media path for all video and audio files and create the given CSV file with following layout, suitable for importing into your favorite spreadsheet application:

filename, ext, size, duration, width, height, fps, aspect "/plex/movies/Catwoman/Catwoman.avi", avi, 1466207024, 01:39:57.680, 720, 304, 25, 2.35:1 

Modifications to these fields should be fairly simple.

Hope someone finds it useful. Comments or recommendations are welcomed.

#!/bin/bash FormatFile="/tmp/inform.txt" FolderRoot="$1" CSVFile="$2" ExtList=".*\.\(mp4\|m4v\|m4p\|mkv\|avi\|asf\|wmv\|flv\|vob\|ts\|mpg\|mpeg\|mts\|m2ts\|webm\|ogv\|mov\|3gp\|3g2\|mp3\|m4a\|ogg\|flac\)" function cleanup () { rm "$FormatFile" } trap "cleanup" EXIT mi=$(which mediainfo) if [ $? -eq 1 ]; then echo "Failed to locate mediainfo on this system. This script won't work without it." exit; fi # Create the Format file used by mediainfo echo 'General;""%CompleteName%"", %FileExtension%, %FileSize%, %Duration/String3%, ' > "$FormatFile" echo 'Video;%Width%, %Height%, %FrameRate%, %DisplayAspectRatio/String%' >> "$FormatFile" # Create CSV file with headers echo "filename, ext, size, duration, width, height, fps, aspect" > "$CSVFile" find "$FolderRoot" -type f -iregex "$ExtList" -exec "$mi" --Inform="file://$FormatFile" {} \; >> "$CSVFile" exit; 

submitted by /u/haz3lnut to r/PleX
[link] [comments]