LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Locating protected WMA files (https://www.linuxquestions.org/questions/linux-general-1/locating-protected-wma-files-694090/)

waberforce 12-31-2008 12:06 PM

Locating protected WMA files
 
Let me start by saying I am not trying to defeat DRM! I also could not locate a similar thread, and google only provides links to 'remove DRM from wma' no matter what I search.

So here is what I am trying to do, I want to find and move all DRM protected audio files out of my library and into its own folder.

I have an extensive audio library that started years ago when I was a windows noob. Like a sheep, I bought into the 'amazing benefits of wma' and ripped all my cds using it. Now I am older and wiser, running Fedora 9 and loving every minute of it. However, that old DRM music is intermixed with my mp3s and it causes issues with Amarok (and others) when they come up in a shuffle.

I have one remaining Windows machine for pic programming that is licensed to play them, and that is fine. I have already re-ripped the cds in linux so I dont need to convert. All I want to do it find out which ones have DRM and move them to a separate folder. Any ideas?

Best Regards and happy new year!

David the H. 12-31-2008 01:02 PM

When you run the 'file' command on a DRM file, does it show anything different in the output compared to a non-DRM file? If so, then you can use grep to filter out a list of the files you want. "ls *.wma | grep <matching-phrase>".

waberforce 12-31-2008 02:01 PM

Thanks!
 
So that was all I needed to jog the creative juices. I did a comparison on a WMA with and without DRM and found a expression that seems to work well. Then a few hundred re-writes later I created this, hope it is useful for someone else too!

Given a directory this will go through and move all DRM files (well maybe not all types, known to work with WMA) to a subdirectory called 'DRM' of the provided directory. It respects found locations.

Example Output(if the script is called move_drm):

Quote:

[me@localhost ~]$move_drm /home/me/repository

FOUND DRM IN: 07 Taiyed.wma
Creating folder '/home/me/repository/DRM/Work/Grassroots'
Moving '/home/me/repository/Work/Grassroots/07 Taiyed.wma' to '/home/me/repository/DRM/Work/Grassroots/'


FOUND DRM IN: 05 Omaha Stylee.wma
Destination Folder Exists
Moving '/home/me/repository/Work/Grassroots/05 Omaha Stylee.wma' to '/home/me/repository/DRM/Work/Grassroots/'


Code:

#!/bin/bash

if [ -z "$1" ]; then
        echo usage: $0 directory
        exit
fi

if [ -d "$1" ]
then
        directory="$1"
else
        echo usage: $0 directory
        echo "  ERROR: $1 is not a valid directory!"
        exit
fi

clear

grep -rl "sbp=DRM" ${directory}/* | grep -v DRM | while read line
do
        echo -e "\n\nFOUND DRM IN: ${line##*/}"

        drm_dir=${line%/*}
        drm_dir=${drm_dir##$directory}
        drm_dir=$directory/DRM${drm_dir}

        if [ -d "$drm_dir" ]
        then
                echo "  Destination Folder Exists"
        else
                echo "  Creating folder '$drm_dir'"
                mkdir -p "$drm_dir"
        fi
        echo "  Moving '$line' to '$drm_dir/'"
        mv -f "$line" "$drm_dir/"
done

echo -e "\n*** COMPLETE ***\n"

Best Regards!


All times are GMT -5. The time now is 01:23 AM.