You are not logged in.
Dear visitor, welcome to Aqua Computer Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
![]() |
Source code |
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)) |
![]() |
Source code |
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)) |
-