Wednesday, November 27, 2013

Organising MusicLibrary and ID3's


The way I find it most convenient to maintain my music library is using
  • ranger (file navigation and moving)
  • rsync (syncing directories)
  • easytag (ID3v2 editor)
  • and vidir (file renaming tool)

Synchronising the content of my music library and the local drive is done with the following simple music_rsync_existing script

# Selective music file and ID3 syncing from external drive (element)
# Music domain lives on the external drive, organised by artist directories
export MUSIC_ELEMENT=/media/automatic/element/box/music/ # External (domain) path
export MUSIC_KNMEDIA=/mnt/knmedia/music/ # Local path

alias music_copy_all="rsync -rv $MUSIC_ELEMENT $MUSIC_KNMEDIA --progress"

# Remove all that artist folders which end with _ (they must be duplicates)
alias music_remove_duplicates="find $MUSIC_KNMEDIA -type d -print| grep -E \"^.*_$\" | xargs -d\"\\n\" rm -rvf"
#                                                   dirdectory         regex                 separator  cmd

#   Alternative regex search: 
# find . -type d -regextype posix-extended -regex '.*_$' -print|xargs -I{} -0 ls -rvf {}

# Individually rsync all artist folders with
music_rsync_existing(){
 music_remove_duplicates;
 for kn_path in $MUSIC_KNMEDIA*; do
     if [ -d "${kn_path}" ]; then
  element_path=$MUSIC_ELEMENT`basename ${kn_path}`
  echo "rsync -rv --update --delete $element_path/ $kn_path/" #--progress
  # Sync only ID3 changes on existing ones, delete the ones that only exist on destination 
  #   (no checksum, only mod date and size)
  rsync -rv --update --delete $element_path/ $kn_path/
     fi
 done
} 
Some useful keys
# Ranger tab jumping <Tab>
# Rename Dirs <Key s> for :shell
:shell vidir
# Edit tags
:shell easytag. 

To update mpd, you'll need mpc and 
mpc update path/to/update-dir/as/defined/in/mpd.con

No comments:

Post a Comment