 25.10.2025, 20:25
25.10.2025, 20:25 Sprache ändern
 Sprache ändern
							
							
							
						 Registrieren
 Registrieren Anmelden
 Anmelden
					
											Sie sind nicht angemeldet.
|   | Quellcode | 
| 1 | aktueller code s.u. | 

|   | 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 36 37 38 39 40 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
MP3sort
=======
Sort music files by trying to extract the artist name from
each filename in the directory and moving the file to a new
subdirectory with the artist's name.
Feel free to change the file extension mask and artist
search pattern to fit your needs.
:Copyright: 2004-2008 Jochen Kupperschmidt
:Date: 13-Nov-2008
:License: MIT
"""
from glob import iglob
import os
import re
EXTENSION = 'mp3'
PATTERN = re.compile('(.+) - .*')
if __name__ == '__main__':
    # Get all filenames with the given extension.
    filenames = filter(os.path.isfile, iglob('*.' + EXTENSION))
    for filename in filenames:
        try:
            # Extract artist name from filename.
            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)) | 
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »Y0Gi« (22. Januar 2013, 03:43)
 
							-
 
  
  
  
  
  
  
 