Last active
April 14, 2020 22:16
-
-
Save danmactough/66350624d87d8924c9cdef1ab3e4e496 to your computer and use it in GitHub Desktop.
Move your entire music library from one directory to another
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 | |
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