Move sub-directories to a new folder or drive, preserving the parent folder tree structure
This is rather specific insofar as it's looking for folders containing a single FLAC file and then moves the folder and parent to a new target folder tree. Adapt to your own circumstances.
#!/bin/bash
OLDTREEROOT=`pwd`
NEWTREEROOT=/target/folder/tree/here
find . -type d | while read FOLDERNAME; do
FILECOUNT=$(find "${FOLDERNAME}" -type f -name '*.flac' | wc -l)
if test $FILECOUNT -eq 1
then
TARGETDIR="$(dirname "${FOLDERNAME:1}")"
mkdir -p "$NEWTREEROOT${FOLDERNAME:1}"
mv "${OLDTREEROOT}${FOLDERNAME:1}" "$NEWTREEROOT$TARGETDIR"
fi
done