I have to rename directories under the root directory with prefix ms_PF and then rename their subdirectories with the modified name of the main directory with an extra _, and then copy all directories and their subs to root as follows:root   maindir1   maindir2           subdir1           subdir2           subdir3maindir1 and maindir2 to be renamed with prefix ms_PF_ and copied direct to root, because maindir2 has subdirectories they will carry the new name of maindir2 which is ms_PF_maindir2 plus and underscor (_) then all subs will be copied to root as follows:ms_PF_maindir1ms_PF_maindir2_subdir1ms_PF_maindir2_subdir2ms_PF_maindir2_subdir3Assistance in this matter is highly appreciated. My attempted solution is something like this, but it actually needs fixing:root_dir=/dwn/icbu_dwn/LLprefix=ms_PF_do_it () {awk '{ print mv $root_dir $prefix ${root_dir/\//_} }' | sh}find $root_dir -depth -type d | do_it
renaming a directory and its subdirs without affecting their files
linux;shell script;rename;perl