Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function get_duration {
- total_len=0
- for file in `pwd`/*; do
- cur_len=$(ffprobe -i $file -show_entries format=duration -v quiet -of csv="p=0")
- cur_len=${cur_len%.*}
- total_len=$((total_len+cur_len))
- done
- echo $total_len
- }
- file_deleted=0
- min_len=$1
- dur=$(get_duration)
- for file in `pwd`/*; do
- if [ ${file: -4} == ".mp3" ]; then
- len=$(ffprobe -i $file -show_entries format=duration -v quiet -of csv="p=0")
- echo -n "$file got lenght of $len "
- if [ ${len%.*} -gt ${min_len} ]; then
- echo "- PRESERVED"
- else
- rm $file
- echo "- DELETED"
- file_deleted++
- fi
- fi
- done
- dur=$(get_duration)
- echo "STATS ---------------------"
- echo "File deleted: $file_deleted"
- echo "Total audio lenght BEFORE deleting: $dur"
- echo "Total audio lenght AFTER deleting: $dur"
- echo "Done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement