Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to check a list of files against a playlist .m3u

Status
Not open for further replies.

macele

Technical User
Oct 24, 2007
1
US
I had a sort of hard disk catastrophe last night, and I was luckily able to recover most of my data, the directories most effected where my music directories. Now I have somewhere on the order of 10K mp3s but I don't know which ones where lost and not. It seems some directories have lost one song and others have lost everything. I have a complete playlist from before the incident and would like to check the playlist against the directory. The playlist is an .m3u type playlist that looks like this:

#EXTM3U
#EXTINF:0,311-11-Don't Stay Home.mp3
\\192.168.1.31\storage\250a\Music\311\311\311-11-Don't Stay Home.mp3

#EXTINF:0,311-15-Love Song.mp3
\\192.168.1.31\storage\250a\Music\311\Greatest Hits '93-'03\311-15-Love Song.mp3

#EXTINF:0,The Academy is-05-Everything We Had.mp3
\\192.168.1.31\storage\250a\Music\The Academy Is\Santi\The Academy is-05-Everything We Had.mp3

Now I am no Linux guru, but I know there must be a way to make a script that can parse this file and check the mp3s to see if they exist. Now I realize that simply verifying the existence of the file means little. Without a hash check there is no way to be sure that the files are not damaged, but I need some place to start.

The file server runs Ubuntu Linux and I can run the script there, so if there is some way to skip the \\192.168.1.31\ part of the file it would be handy.

I really need your help here guys,
Thanks.
 
Hi there,

you could try something like this:

----------------------------------------------------------
cat playlist.m3u | grep cut -c 16-500 > /tmp/playlist-workfile.txt

for items in `cat /tmp/playlist-workfile.txt`
do
find / | grep $items > /dev/null
if [ $? = 0 ]; then
echo "found: $items" >> /tmp/results.txt
else
echo "missing: $items" >> /tmp/results.txt
fi
done
----------------------------------------------------------

If you only want missing files to be reported you could e.g. change the script so that if "$? = 0" no entry is made in the file ...

Regards
Thomas
 
Well let's build a (sort of) oneliner for you:

first change all the \ to /:

tr '\\' '/' </path/to/yourfile

then, pipe that output to a filter to show just the lines with //192.168.1.31/ at the start of a line:

tr '\\' '/' </path/to/yourfile|grep -e '^//192.168.1.31/'

then, strip off the first 14 characters:

tr '\\' '/' </path/to/yourfile|grep -e '^//192.168.1.31/'|cut -c15-

now we have a list of all te pathnames of the files you think should be there, pipe that output to a loop to find out if a file is found

tr '\\' '/' </path/to/yourfile|grep -e '^//192.168.1.31/'|cut -c15-|while read path
do
test -f "${path}" && echo ${path} is there
done

the quotes around ${path} are needed because of spaces in your file names...

Now we're only interested in files that aren't there, so let's negate the test:

tr '\\' '/' </path/to/yourfile|grep -e '^//192.168.1.31/'|cut -c15-|while read path
do
test ! -f "${path}" && echo ${path} is not there
done

Now to put just the list of missing files in a textfile:

Code:
tr '\\' '/' </path/to/yourfile|grep -e '^//192.168.1.31/'|cut -c15-|while read path
do
 test ! -f "${path}" && echo ${path}
done >/tmp/missing_mp3.txt




HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top