Hi, couldn't help myself.
There is an easier way then using 3 for-loops to do this
You know that the directory depth is minimum 3 right?
# You know what this is :)
# Just to make sure incase any directory contains a whitespace character, you can remove this safely if these doesn't exist
# The magic find :) -mindepth is the trick
for i in $(find $source -mindepth 3 -type d -iname \*); do
# create the new path
tmp=$(echo $i | replace "$source" "$dest")
# move the files from $i -> $tmp which is the new dest
mv "$i" "$tmp"
I haven't tested this, but something like that should work. You can also specify -maxdepth with find incase you wish to lock yourself in a directory depth.