Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2013 05:35
Show Gist options
  • Save anonymous/4481502 to your computer and use it in GitHub Desktop.
Save anonymous/4481502 to your computer and use it in GitHub Desktop.
m3u to sync dir of hardlinks
#/bin/sh
ROOTDIR=/media/storage/sounds
pushd "${ROOTDIR}"
grep -v '^#' music/Checked.m3u | sed -e 's./Volumes/storage/sounds/..' | \
while read TRACK
do
if [ -e "${TRACK}" ]
then
DESTDIR=$(echo "${TRACK}" | sed -e "s/^music/sync/")
if [ ! -e "${DESTDIR}" ]
then
mkdir -p "${DESTDIR}"
fi
pushd "${DESTDIR}" > /dev/null
ln "${ROOTDIR}/${TRACK}"
popd > /dev/null
else
echo "could not find ${TRACK}"
fi
done
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment