Skip to content

Instantly share code, notes, and snippets.

@danmactough
Last active April 14, 2020 22:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danmactough/66350624d87d8924c9cdef1ab3e4e496 to your computer and use it in GitHub Desktop.
Save danmactough/66350624d87d8924c9cdef1ab3e4e496 to your computer and use it in GitHub Desktop.
Move your entire music library from one directory to another
#!/bin/bash
set -euo pipefail
set -x
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# set OLD_DIRECTORY and NEW_DIRECTORY
# OLD_DIRECTORY=/Users/your_username/Music
# NEW_DIRECTORY=/Volumes/your_external_drive/Music
OLD_DIRECTORY=
NEW_DIRECTORY=
for DIR in $OLD_DIRECTORY/*
do
if [ -d "$DIR" ]
then
echo "Moving $(basename "${DIR}")..."
cp -R "${DIR}" "${NEW_DIRECTORY}"
fi
done
# restore $IFS
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment