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-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  for this_high_dir in ${music_dir}
13  do
14    # Scan for artists
15    echo "Scanning ${this_high_dir} directory ..."
16    ls -1 "${base_dir}/${this_high_dir}" > ${tmpy}/${this_high_dir}
17    while read artist
18    do
19      # Work out if we already have a directory for this artist
20      if [ ! -d "${base_dir}/${hq_dir}/${artist}" ]; then
21        mkdir "${base_dir}/${hq_dir}/${artist}"
22      fi
23      # Scan for tracks
24      echo " Found ${artist} - scanning for albums ..."
25      ls -1 "${base_dir}/${this_high_dir}/${artist}" > ${tmpy}/${this_high_dir}-${artist}
26      while read album
27      do
28        # Create a symbolic link to the album
29        if [ ! -L "${base_dir}/${hq_dir}/${artist}/${album}" ]; then
30          echo " Linking to ${album}"
31  ln -s "../../${this_high_dir}/${artist}/${album}" "${base_dir}/${hq_dir}/${artist}/${album}"
32        fi
33      done <${tmpy}/${this_high_dir}-${artist}
34    done <${tmpy}/${this_high_dir}
35  done



Del.ico.us Digg Facebook Google LinkedIn LiveJournal NewsVine reddit StumbleUpon Twitter
Valid XHTML 1.0 Transitional Valid CSS! [Valid Atom 1.0] [Valid RSS 2.0]
[ Page last updated Fri 29th Jan 2016 | viewed 11356 times ]