Sie sind nicht angemeldet.
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#!/usr/bin/env python
"""mp3sort.py -- Version 17-Oct-2004
Tries to extract the artist name from each mp3 file in the directory and moves
the file to a subdirectory with the artist's name. Feel free to change the
file mask and artist search expression to fit your needs.
Copyright (c) 2004 Jochen Kupperschmidt <webmaster@homework.nwsnet.de>
Released under the terms of the GNU General Public License
_ _
| |_ ___ _____ ___ _ _ _ ___ ___| |_
| | . | | ._| | | | . | _| . /
|_|_|___|_|_|_|___|_____|___|_| |_|_\
[url]http://homework.nwsnet.de/[/url]
"""
import glob
import os
import os.path
import re
pattern = re.compile('(.+) - .*')
for filename in glob.glob('*.m3u'):
if not os.path.isfile(filename):
continue
try:
dirname = pattern.match(filename).group(1).strip()
except AttributeError:
pass
else:
if not os.path.isdir(dirname):
os.mkdir(dirname)
os.rename(filename, os.path.join(dirname, filename))
|
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import glob
import os
import os.path
import re
pattern = re.compile('.* - (.+).m3u')
for filename in glob.glob('*.m3u'):
if not os.path.isfile(filename):
continue
try:
dirname = pattern.match(filename).group(1).strip()
except AttributeError:
pass
else:
if not os.path.isdir(dirname):
os.mkdir(dirname)
os.rename(filename, os.path.join(dirname, filename))
|
-