I have come across this problem too and wrote a python function to fix it; my advice is to cut your losses with the DRM files and just move them out of whatever program you are using for playlists etc. The typical issue is m4p's mixed in with your mp3's and m4a's; whatever your mix this will move all drm'd files into a new folder at C:\drm_music
:
import os, shutil
def move_drm_files(music_folder):
all_songs = []
good_filetypes = ['mp3', 'm4a', 'ogg', 'flv', 'wma']
for root, dirs, files in os.walk(music_folder):
for name in files:
full_name = os.path.join(root, name)
all_songs.append(full_name)
os.mkdir('/drm_music')
for song in all_songs:
if song[-3:] not in good_filetypes:
shutil.move(song, '/drm_music')
So for example you could run the above with python -i move_drm.py
(saving the script as move_drm.py
) and call move_drm_files('/users/alienfluid/music')
, and all the drm'd filetypes would be moved to their own quarantined folder. If you think you can save some of those you could do this to sort the drm files by type:
def sort_drm(drm_folder, all_songs=[]):
os.mkdir('/drm_collection')
known_types = []
for root, dirs, files in os.walk(drm_folder):
for name in files:
full_name = os.path.join(root, name)
all_songs.append(full_name)
for item in all_songs:
if item[-3:] not in known_types:
known_types.append(item[-3:])
for item in known_types:
os.mkdir('/drm_collection/'+item)
for item in all_songs:
shutil.copy2(item, '/drm_collection/'+item[-3:])
This will create a folder at C:\drm_collection
with subfolders named for their extension (m4p etc), and they will be filled with all instances of each type; if you run the first function, you could just save the second one in the same file and call sort_drm('/drm_music')