I would like to count all of all mp3 files in one directory.
import os
from subprocess import check_output
directory = r'c:\test'
sum = 0
for filename in os.listdir(directory):
if filename.endswith(".mp3"):
a = str(check_output('ffprobe -i "'+filename +'" 2>&1 |findstr "Duration"',shell=True))
a = a.split(",")[0].split("Duration:")[1].strip()
h, m, s = a.split(':')
duration = int(h) * 3600 + int(m) * 60 + float(s)
print(os.path.join(directory, filename, duration))
sum = sum + duration
sum = round(sum)
print("sum", sum)
time = datetime.timedelta(seconds=sum)
print(str(time))
I get this error, but I don't know why. can someone help me fix the error? many thanks
File "loop.py", line 10
a = str(check_output('ffprobe -i "'+filename+'" 2>&1 |findstr "Duration"',shell=True))
^
TabError: inconsistent use of tabs and spaces in indentation