LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-31-2008, 12:06 PM   #1
waberforce
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Rep: Reputation: 0
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!
 
Old 12-31-2008, 01:02 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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>".
 
Old 12-31-2008, 02:01 PM   #3
waberforce
LQ Newbie
 
Registered: Dec 2008
Posts: 2

Original Poster
Rep: Reputation: 0
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to play DRM protected WMA files in Linux danishmr Linux - Software 33 05-11-2010 02:26 PM
playing drm protected wma files in linux ZaphyR Linux - General 33 12-27-2008 11:27 AM
For people how want to play WMA files without converting MP3 files waelaltaqi Linux - Software 15 11-17-2005 08:30 AM
Locating Installed Programs /or Files Mr T Donegal Linux - Software 5 06-28-2004 08:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration