First, I created your directory tree with
[root@localhost /tmp]# mkdir -pv directory/folderA/2017/06 directory/folderA/2016/{10..12} directory/2017/{04..06} directory/2016
Then I created your example files with:
[root@localhost /tmp]# touch directory/{,folderA}/2017/06/info.log
Last, I used rsync with the --delete-after to move instead of rsync's default behavior which would create a copy instead:
[root@localhost /tmp]# rsync --delete-after -a directory/folderA/ directory
Note: the trailing '/' after the source directory (ie. directory/folderA/ as opposed to directory/folderA) is required if you want the directories to be deleted after they are copied.
Of course, if you really wanted to type mv to obtain the desired behavior you could create a custom shell function. I'm not advocating this, but it is possible. Sloppy, but possible.
Here's a custom function you could add to your ~/.bashrc:
function mv() {
if [[ "$@" =~ .*--delete-after.*-av*.* ]]; then
rsync $@
else
command mv $@
fi; }
Then invoke the updated ~/.bashrc by logging out and logging back in -or- by typing:
[root@localhost /tmp]# exec bash
Now you can test your custom function with either:
[root@localhost /tmp]# mv --delete-after -av directory/folderA/ directory
to get verbose output,
or with:
[root@localhost /tmp]# mv --delete-after -a directory/folderA/ directory
to receive only errors if any are encountered.
As an aside, you can also avoid piping yes to the cp -rf command by issuing your cp command with a preceding backslash like this:
[root@localhost /tmp]# \cp -rf directory/folderA/* directory/
The reason you are piping yes is you likely have an alias for the cp command in your ~/.bashrc such as this:
[root@localhost /tmp]# alias cp='cp -i'
which you can verify by typing:
[root@localhost /tmp]# type cp