Sunday, July 15, 2012

Shell tips



filename="all you need is love - the beatles.mp3"
ext=$(echo $filename | grep -o '\....$')
title=$(echo $filename | sed 's/ - .*//; s/\b\w/\u&/')
artist=$(echo $filename | sed "s/.* - \(.*\)$ext/\1/; s/\b\w/\u&/g")
echo $title - $artist$ext

All you need is love - The Beatles.mp3

No comments: