Skip to content

Instantly share code, notes, and snippets.

@AaronJackson
Created November 19, 2013 23:54
Show Gist options
  • Save AaronJackson/7554807 to your computer and use it in GitHub Desktop.
Save AaronJackson/7554807 to your computer and use it in GitHub Desktop.
Used to update hard links based on a file called links. Requires hlink and hulink. I'm using this to put the music I want to sync to my phone into a specific directory, as BitTorrent Sync does not follow symlinks.
#!/bin/bash
cd "/Volumes/Marceline/MusicSync/"
# first unlink files which have been removed
for artist in *; do
if [ -d "$artist" ]; then
if ! grep -Fxq "$artist" "links" ; then
echo Unlinking $artist
hulink "$artist"
fi
fi
done
# link any new ones
while read artist; do
if [ ! -d "$artist" ]; then
echo Linking $artist
hlink "../Music/$artist" "$artist"
fi
done < links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment