Search code examples
mv

mv: "Directory not Empty" - how do you merge directories with `mv`?


I tried to deploy my personal blog website to my remote server recently. When I tried to move a few files and directories to another place by executing mv, some unexpected errors happened. The command line echoed "Directory not Empty". After doing some googling, I tried again with '-f' switch or '-v', the same result showed. I logged in on the root account, and the process is here:

root@danielpan:~# shopt -s dotglob
root@danielpan:~# mv /var/www/html/wordpress/* /var/www/html
mv: cannot move `/var/www/html/wordpress/wp-content` to `/var/www/html/wp-content`: 
Directory not empty
root@danielpan:~# mv -f /var/www/html/wordpress/* /var/www/html
mv: cannot move `/var/www/html/wordpress/wp-content` to `/var/www/html/wp-content`:
Directory not empty

Anybody know why?

(I'm running Ubuntu 14.04)


Solution

  • I found the solution finally. Because the /var/www/html/wp-content already exists, then when you try to copy /var/www/html/wordpress/wp-content there, error of Directory not Empty happens. So you need to copy /var/www/html/wordpress/wp-content/* to /var/www/html/wp-content. Just execute this:

    mv /var/www/html/wordpress/wp-content/* /var/www/html/wp-content
    rmdir /var/www/html/wordpress/wp-content
    rmdir /var/www/html/wordpress