Skip to content

Instantly share code, notes, and snippets.

@daniel-san
Created May 8, 2012 13:37
Show Gist options
  • Save daniel-san/2635072 to your computer and use it in GitHub Desktop.
Save daniel-san/2635072 to your computer and use it in GitHub Desktop.
Script for organizing a music directory
#!/bin/bash
#Script for organize a directory of songs
#This script create directory for song authors, sub-directories for albums
#and copy the respective album songs to the respective directory
a=`ls *.mp3 | cut -d "-" -f 1 | uniq`
#mkdir $a
for i in $a
do
#echo $i
mkdir $i
b=`ls *.mp3 | grep $i | cut -d "-" -f 2 | uniq`
for j in $b
do
mkdir $i/$j
c=`ls *.mp3 | grep $j`
for k in $c
do
d=`echo $k | grep $j | cut -d "-" -f 3 | uniq`
cp $k $i/$j/$d
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment