Skip to content
Advertisement

mv: cannot overwrite directory with non-directory

Is it possible to get around this problem?

I have a situation where I need to move some files to 1 directory below.

/a/b/c/d/e/f/g

problem is that the filename inside g/ directory is the same as the directory name

and I receive the following error:

mv: cannot overwrite directory `../297534' with non-directory

Example: /home/user/data/doc/version/3766/297534 is a directory, inside there is a also a file named 297534

so I need to move this file to be inside /home/user/data/doc/version/3766

Command This is what I am running: (in a for loop)

cd /home/user/data/doc/version/3766/297534
mv * ../

Advertisement

Answer

You can’t force mv to overwrite a directory with a file with the same name. You’ll need to remove that file before you use your mv command.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement