bash flatten directory

C++
find /dir1 -mindepth 2 -type f -exec mv -t /dir1 -i '{}' +

Source

Also in C++: