File [scripts/hq_music_linker.sh]
| 1 |
#!/bin/sh |
| 2 |
base_dir="${HOME}/Music" |
| 3 |
hq_dir="highest-quality-links" |
| 4 |
music_dir="flac mp3-320kbit mp3-240kbit mp3-160kbit mp3-128kbit" |
| 5 |
# Create a tmp directory for dumps |
| 6 |
tmpy=/tmp/hq_music_linker |
| 7 |
if [ ! -d "${tmpy}" ]; then |
| 8 |
mkdir ${tmpy} |
| 9 |
fi |
| 10 |
# Flush out the hq directory first of all |
| 11 |
rm -Rf ${base_dir}/${hq_dir}/* |
| 12 |
artists=0 |
| 13 |
albums=0 |
| 14 |
for this_high_dir in ${music_dir} |
| 15 |
do |
| 16 |
# Scan for artists |
| 17 |
echo "Scanning ${this_high_dir} directory ..." |
| 18 |
ls -1 "${base_dir}/${this_high_dir}" > ${tmpy}/${this_high_dir} |
| 19 |
while read artist |
| 20 |
do |
| 21 |
# Work out if we already have a directory for this artist |
| 22 |
if [ ! -d "${base_dir}/${hq_dir}/${artist}" ]; then |
| 23 |
mkdir "${base_dir}/${hq_dir}/${artist}" |
| 24 |
artists=`expr $artists + 1` |
| 25 |
fi |
| 26 |
# Scan for tracks |
| 27 |
echo " Found ${artist} - scanning for albums ..." |
| 28 |
ls -1 "${base_dir}/${this_high_dir}/${artist}" > ${tmpy}/${this_high_dir}-${artist} |
| 29 |
while read album |
| 30 |
do |
| 31 |
# Create a symbolic link to the album |
| 32 |
if [ ! -L "${base_dir}/${hq_dir}/${artist}/${album}" ]; then |
| 33 |
echo " Linking to ${album}" |
| 34 |
ln -s "../../${this_high_dir}/${artist}/${album}" "${base_dir}/${hq_dir}/${artist}/${album}" |
| 35 |
albums=`expr $albums + 1` |
| 36 |
fi |
| 37 |
done <${tmpy}/${this_high_dir}-${artist} |
| 38 |
done <${tmpy}/${this_high_dir} |
| 39 |
done |
| 40 |
echo "" |
| 41 |
echo "Found and linked ${artists} artists and ${albums} albums." |



![Validate my Atom 1.0 feed [Valid Atom 1.0]](./images/valids/valid-atom10-yellow.gif)
![Validate my RSS 2.0 feed [Valid RSS 2.0]](./images/valids/valid-rss20-yellow.gif)