Last active
February 9, 2018 23:00
-
-
Save rveachkc/eaf223a25c5737b90459a355393766aa to your computer and use it in GitHub Desktop.
Search for playlists, and move them all into an import directory.
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 | |
# This is a script I'm using to copy m3u playlist files from my music library into an import directory for Airsonic. | |
# This will flatten out the directory structure and also remove files in the destination that are no longer in the source. | |
# please test the configurable variables with rsync's --dry-run. | |
# configurables | |
## Location to search for m3u playlists recursively | |
PLAYLIST_EXPORT_DIR=/<path>/<to>/<search>/<for>/<playlists> | |
PLAYLIST_DESTINATION=/<path>/<to>/<save>/<playlists> | |
# create temp directory to keep files | |
TEMPDIR=$(mktemp -d) | |
# copy all m3u files to tempdir | |
# this will store all files in the root of $TEMPDIR | |
find ${PLAYLIST_EXPORT_DIR} -type f -iname '*.m3u' -exec cp {} ${TEMPDIR}/. \; | |
# rsync to copy all from tempdir | |
# this will also delete all files that are no longer present in the source | |
rsync -av --delete-before --include='*.m3u' --exclude='*' ${TEMPDIR}/ ${PLAYLIST_DESTINATION}/ | |
# remove tempdir | |
rm -rf $TEMPDIR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment