Sorting mp3


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sorting mp3
# 1  
Old 05-11-2005
Hammer & Screwdriver Sorting mp3

Hi all...

Here's my question:
-> considering i've got thousands of mp3s', named like "Artist name - Track Name", how could i write a shell (ksh, or bash my favorite, not knowinf enough any other language) that would create a directory (if not existing already) with the Artist's name, and move the corresponding files in it?
i've gave it a try with awk, but i can't get by the spaces in artists's name/track name...
And yes, another thing as soon as there are more than 2 songs of a same artist, create the directory..

Any suggestions would help!! A complet script would be ok, but help to build my one will be fine too!

Thanx all..


Jason

Last edited by penguin-friend; 05-11-2005 at 12:27 PM..
# 2  
Old 05-12-2005
Tools

I have not tested this...

See this if it works for you

################################################

#!/usr/bin/ksh

MP3DIR="where your mp3 resides"

ls -1 $MP3 > tmpfile
awk -F"-" '{ print $1 }' tmpfile > tmpfile1
uniq tmpfile1 > tmpfile2

while read LINE
do
count=`find $MP3DIR -name "*$LINE*" -print | wc -l`
if [ $count -gt 1 ]; then
mkdir $MP3DIR/$LINE > /dev/null
mv $LINE* $MP3DIR/$LINE
fi
done < tmpfile2

rm -f tmpfile*

################################################
# 3  
Old 05-12-2005
Yep!

Thanx it seems to work!
I tested the first part (ie before the while loop), and that worked.
I didn't think of using tmp files, i tried to awk with the same options, working directly on the output of a ls -1:
ls -1 *.mp3 | awk -F"-" '{print $1}' as artists names. Any ideas why that won't work?
# 4  
Old 05-13-2005
Power

I dont see any reaon why this should not work.

See the sample run.

arfwsp04% ls -ltr
total 32
drwxr-xr-x 2 arbor arboradm 96 Apr 27 02:50 atr
drwxr-xr-x 3 arbor arboradm 96 Apr 27 07:21 atr_prod
-rw-r--r-- 1 arbor arboradm 149 May 11 00:23 data
-rw-r--r-- 1 arbor arboradm 5656 May 12 03:05 da_report
drwxr-xr-x 4 arbor arboradm 4096 May 13 01:25 final
drwxr-xr-x 2 arbor arboradm 96 May 13 01:33 tt
-rw-r--r-- 1 arbor arboradm 0 May 13 03:09 a-1.x
-rw-r--r-- 1 arbor arboradm 0 May 13 03:09 a-2.x
-rw-r--r-- 1 arbor arboradm 0 May 13 03:09 a-3.x
-rw-r--r-- 1 arbor arboradm 0 May 13 03:19 b1-1.x
-rw-r--r-- 1 arbor arboradm 0 May 13 03:19 b1-2.x
arfwsp04% ls -1 | awk -F"-" '{print $1}'
a
a
a
atr
atr_prod
b1
b1
da_report
data
final
tt


You say...you can do away with tempfiles...I will like to know..how will u do that..

Thanks
Rishi
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I'm trying to remove all mp3's in subdirectories

My company has a policy that employees can't keep music on our servers so im looking for a line or script that I can run as part of a cron job that will remove all mp3's in the users home directories. Does anyone have any idea how I might accomplish this? (3 Replies)
Discussion started by: binary-ninja
3 Replies

2. Shell Programming and Scripting

Check file is mp3

Hello, I am trying to check if a file is an mp3. file -b file_path g ives me AUDIO for many MP3 but there are many working MP3 files that return something else. How can I get better result? Thank you (2 Replies)
Discussion started by: JCR
2 Replies

3. Shell Programming and Scripting

Batch MP3 transcoding.

Hello everyone, I've made a script and I want to share and get new ideas for improving it. So far, the script 1. Searches a directory tree for MP3 files; 2. Check their bitrates; 3. Change any bitrate higher than 128 kbps to VBR 4 (It ignores files with a bitrate lower or equal to 128, as... (3 Replies)
Discussion started by: lvxferre
3 Replies

4. UNIX for Dummies Questions & Answers

Opening an mp3 with a different application

I would like to know how to open an mp3 with an application other than it's default app. For instance, instead of opening with iTunes, I would like it to open with quicktime. Any help would be appreciated. Thanks!! (1 Reply)
Discussion started by: emperorfabulous
1 Replies

5. UNIX for Dummies Questions & Answers

mp3 codec

I just need a mp3 codec that will decode mp3s so I can play them with my media player (probably going to be using XMMS) (0 Replies)
Discussion started by: Synbios
0 Replies

6. OS X (Apple)

osx mp3 player help

Hey UNIX Saviors, I am not very familiar with unix commands so I need some detailed help please. I have a RCA Lyra MP3 player that is supposed to work as a drag and drop external drive when transferring my MP3's. In OSX, the problem is that when I delete the MP3 from the mounted drive it... (1 Reply)
Discussion started by: eideas
1 Replies

7. UNIX Desktop Questions & Answers

MP3 driver for Unix

I need to play mp3 sound files on unix platform. Is there any mp3 drivers available for unix (rue unix-64 and unixware 7.0)? (3 Replies)
Discussion started by: parbende
3 Replies
Login or Register to Ask a Question