Skip to content

Instantly share code, notes, and snippets.

@danmactough danmactough/move-music.sh
Last active Apr 14, 2020

Embed
What would you like to do?
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
You can’t perform that action at this time.