files/id3guess

25 lines
705 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
import re
from subprocess import Popen, PIPE
sys.stdout.write('Artist: ')
sys.stdout.flush()
artist = sys.stdin.readline().strip()
sys.stdout.write('Album: ')
sys.stdout.flush()
album = sys.stdin.readline().strip()
sys.stdout.write('Year: ')
sys.stdout.flush()
year = sys.stdin.readline().strip()
for f in sorted(os.listdir('.')):
m = re.match('(\d+)[\s.](.*)\.mp3', f, re.I)
if m is not None:
track, title = m.group(1, 2)
title = re.sub(r'_', ' ', title)
sys.stdout.write('%s: Track "%s", Title "%s"\n' % (f, track, title))
Popen(['id3tag', '-a', artist, '-A', album, '-y', year, '-t', track, '-s', title, f]).wait()