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 subdir3 maindir1 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_maindir1 ms_PF_maindir2_subdir1 ms_PF_maindir2_subdir2 ms_PF_maindir2_subdir3 Assistance in this matter is highly appreciated. My attempted solution is something like this, but it actually needs fixing:
root_dir="/dwn/icbu_dwn/LL" prefix="ms_PF_" do_it () { awk '{ print "mv $root_dir $prefix ${root_dir/\//_}" }' | sh } find "$root_dir" -depth -type d | do_it
${root_dir/\//_}substitution requires bash/zsh/ksh -- probably won't work with plain sh.