Created
February 6, 2019 05:32
-
-
Save maxcohn/77b5333ca879e8beeb6acf56f70d1f6f to your computer and use it in GitHub Desktop.
Calculates the total amount of time of MP3 files in the current directory. Uses Mutagen library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get total time of all mp3 files in the current directory (1/21/19) | |
import os | |
from mutagen.mp3 import MP3 | |
total = 0 | |
for file in os.listdir("."): | |
if not file.endswith(".mp3"): continue | |
audio = MP3(file) | |
total += audio.info.length | |
hours = total / 60 / 60 | |
print(f"Total hours = {hours}") | |
input("Press enter to exit.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment