cp: cannot overwrite directory with non-directory
Slackware 13.37 x64, cp (GNU coreutils) 8.11
The error as in subject occurred to me when I tried to upgrade Mediawiki on the remote Ubuntu server. I don't have access to this server at the moment but the flow that led me the error was as follows: Code:
mkdir ~/symlinks |
The error occurs, in your example, because when you copy the symlink called 'symlink' into the directory called 'dir', there is already an object named 'symlink' residing there, although it is a directory! Understanding the situation was made harder by the rather confusing names!
If you try this: cd ~/symlinks rmdir dir/symlink cp -r symlink dir/ .. then you should find in 'dir' a new copy of the symlink called 'symlink' pointing to the directory ~/symlinks-target (which should work as long as the link was created with an absolute path not a relative one). Will this accomplish what you want? |
Yes, it will, and I know it:
Quote:
|
Ah, sorry, my mistake -- I missed the part of your OP that you just quoted.
So you need to detect when there is already a directory there, if so remove it, and replace with a symlink of the same name to somewhere else? Someone may come up with some really nifty way of doing that with a combo of find and xargs or something, but for safety yes I would have thought a script would be needed. Because, as you say, of the "pitfalls". You might be able to work around it by making sure all the objects you are replacing are always symlinks, and never actual directories. This could work for keeping a set of files up-to-date when only some are superseded on each update, if that's your situation for example. |
mv: cannot overwrite non-directory
Hi, I am trying to transfer some test files older than a specific date to another directory. I get the same error when I try to run my script.
find /INTER/f/d/o/ -name 'test*.txt' -mtime +190 -type f -exec mv /ARCHIVE/f/d/o/ {} \; mv: cannot overwrite non-directory ./test1.txt with directory /ARCHIVE/f/d/o mv: cannot overwrite non-directory ./test2.txt with directory /ARCHIVE/f/d/o mv: cannot overwrite non-directory ./test3.txt with directory /ARCHIVE/f/d/o mv: cannot overwrite non-directory ./test4.txt with directory /ARCHIVE/f/d/o Can someone please give me any suggestions on what to do. I have been changing this script multiple times with no success and searching the web. Thanks |
please open a dedicated thread and take the time and effort to formulate a full problem description.
the first link in my signature might help. please use code tags for adding code to your post. |
All times are GMT -5. The time now is 07:11 AM. |