Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.84 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function get_duration {
  4.   total_len=0
  5.   for file in `pwd`/*; do
  6.     cur_len=$(ffprobe -i $file -show_entries format=duration -v quiet -of csv="p=0")
  7.     cur_len=${cur_len%.*}
  8.     total_len=$((total_len+cur_len))
  9.   done
  10.   echo $total_len
  11. }
  12.  
  13. file_deleted=0
  14. min_len=$1
  15. dur=$(get_duration)
  16. for file in `pwd`/*; do
  17.   if [ ${file: -4} == ".mp3" ]; then
  18.     len=$(ffprobe -i $file -show_entries format=duration -v quiet -of csv="p=0")
  19.     echo -n "$file got lenght of $len "
  20.     if [ ${len%.*} -gt ${min_len} ]; then
  21.       echo "- PRESERVED"
  22.     else
  23.       rm $file
  24.       echo "- DELETED"
  25.       file_deleted++
  26.     fi
  27.   fi
  28. done
  29.  
  30. dur=$(get_duration)
  31. echo "STATS ---------------------"
  32. echo "File deleted: $file_deleted"
  33. echo "Total audio lenght BEFORE deleting: $dur"
  34. echo "Total audio lenght AFTER deleting: $dur"
  35. echo "Done."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement