diff options
author | Rasmus Steinke <rasi@xssn.at> | 2012-08-11 02:40:34 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2012-08-11 02:40:34 +0200 |
commit | f140a1642ebfde198946ad6760c1003c1cb9a8c3 (patch) | |
tree | 7538aa90092f99c661ec3abb4a69944767315dc5 /bin/fixdate | |
parent | e3fd45703267ce67d8b1e1fb53a4a1b4ccda551e (diff) | |
download | dotfiles-f140a1642ebfde198946ad6760c1003c1cb9a8c3.tar.gz dotfiles-f140a1642ebfde198946ad6760c1003c1cb9a8c3.tar.xz |
scripts
Diffstat (limited to 'bin/fixdate')
-rwxr-xr-x | bin/fixdate | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/fixdate b/bin/fixdate new file mode 100755 index 0000000..3fc641b --- /dev/null +++ b/bin/fixdate @@ -0,0 +1,28 @@ +#!/usr/bin/env python2 +"""Deletes the day and month from the 'date' tag in music files""" +import sys +try: + import mutagen +except ImportError: + sys.exit("You need mutagen to use this") + +from os import walk +from os.path import join + +if len(sys.argv) == 2: + basedir = sys.argv[1] +else: + sys.exit("Usage: %s directory" % sys.argv[0]) + +for root, dirs, files in walk(basedir): + for name in files: + print "Working on %s:" % join(root, name), + mufile = mutagen.File(join(root, name), easy=True) + if mufile is not None: + if "date" in mufile.keys(): + mufile["date"] = [mufile["date"][0][:4]] + mufile.save() + print mufile["date"][0] + else: + print "No date to fix :-( " + |