move directories up one level

hi , could you help me with shell scripting

in a shell script i have these commands

a=`ls -R $dir | grep ./ `
cp -R ./$a/* ./$output/

with the first command i have all the directories with the second command i want to copy them in a new directory something like this

old/old/insomnia/1.mp3
old/old/linux/insomnia/sd/2.avi
old/old/linux/insomnia/sd/3.avi

and the new directory tha the script will create is

new/insomnia/1.mp3
new/sd/2.avi
new/sd/3.avi

thanks in advance !!!

I understand nothing. Why don't you just

cp -r OLDIR NEWDIR

with the first command i have all the subdirectories

with the second command i want to copy them to a new directory

but when i try the cp -r olddir newdir it doesn't work

even if the ls command show the directories the copy command throws an error like

cp stat :can't find directories to copy (something like that)