Created
November 19, 2013 23:54
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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