My Dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

16 lines
780 B

  1. #!/usr/bin/env bash
  2. shopt -s nullglob
  3. let playlist_duration_ms=0
  4. for song_file in *.{mp3,ogg,m4a,flac,wav}; do
  5. playlist_duration_ms=$(expr $playlist_duration_ms + $(mediainfo --Inform="Audio;%Duration%" "$song_file"))
  6. done
  7. shopt -u nullglob
  8. let playlist_duration_secs=$(expr $playlist_duration_ms / 1000)
  9. let playlist_duration_mins=$(expr $playlist_duration_ms / 60000)
  10. let playlist_duration_remaining_secs=$(expr $playlist_duration_secs - $(expr $playlist_duration_mins \* 60))
  11. let playlist_duration_hours=$(expr $playlist_duration_mins / 60)
  12. let playlist_duration_remaining_mins=$(expr $playlist_duration_mins - $(expr $playlist_duration_hours \* 60))
  13. echo $playlist_duration_hours hours, $playlist_duration_remaining_mins minutes, $playlist_duration_remaining_secs seconds