Skip to main content
added 517 characters in body
Source Link

You could do it in two steps, first moving the files and then deleting the now empty parent directory:

mkdir -p to/there
mv from/here/* to/there
rmdir from/here

In your concrete case, the fragment

if [[ "$stringOldDir" == "$stringNewDir" ]] ; then  
   echo "Match strings "$stringOldDir" and "$stringNewDir""
   if [[ ! -d "move_to" ]] ; then
     mkdir -v "$move_to"
     mv -vf "$OldDirName" "$move_to" 
   else
     mv -fv "$OldDirName" "$move_to" 
   fi
 fi

can be replaced by something like this:

mkdir -p "$move_to/$OldDirName"
mv "$OldDirName"/* "$move_to/$OldDirName"
rmdir "$move_to/$OldDirName"

You could do it in two steps, first moving the files and then deleting the now empty parent directory:

mkdir -p to/there
mv from/here/* to/there
rmdir from/here

You could do it in two steps, first moving the files and then deleting the now empty parent directory:

mkdir -p to/there
mv from/here/* to/there
rmdir from/here

In your concrete case, the fragment

if [[ "$stringOldDir" == "$stringNewDir" ]] ; then  
   echo "Match strings "$stringOldDir" and "$stringNewDir""
   if [[ ! -d "move_to" ]] ; then
     mkdir -v "$move_to"
     mv -vf "$OldDirName" "$move_to" 
   else
     mv -fv "$OldDirName" "$move_to" 
   fi
 fi

can be replaced by something like this:

mkdir -p "$move_to/$OldDirName"
mv "$OldDirName"/* "$move_to/$OldDirName"
rmdir "$move_to/$OldDirName"
added 22 characters in body
Source Link

You could do it in two steps, first moving the files and then deleting the now empty parent directory:

mkdir -p to/there
mv from/here/* /to/there
rmdir from/here

You could do it in two steps, first moving the files and then deleting the now empty parent directory:

mv from/here/* /to/there
rmdir from/here

You could do it in two steps, first moving the files and then deleting the now empty parent directory:

mkdir -p to/there
mv from/here/* to/there
rmdir from/here
Source Link

You could do it in two steps, first moving the files and then deleting the now empty parent directory:

mv from/here/* /to/there
rmdir from/here