2

I am trying to move all files in the current directory to the directory GuardDog-CMS. Now all the files are actually identical, but the files in the current directory are more up-to-date. So when I do the move, I also want to make sure it doesn't prompted me with "file already exists" or anything like that. So I try the following:

~/Documents/github/GuardDog-CMS-TEMP/guarddog //current directory
~/Documents/github/GuardDog-CMS               //destination directory
mv -v . ../../GuardDog-CMS

But it gives me this error:

mv: rename . to ../../GuardDog-CMS/.: Invalid argument

2 Answers 2

1

You get invalid argument because you used dot (.). Your command is trying to rename current directory to ../../GuardDog-CMS, but this is impossible because in Unix like systems slashes are not allowed in filenames.

Use * if you want to move everything from the current directory:

mv -v * ../../GuardDog-CMS

If you have hidden files in the current directory, use shopt -s dotglob nullglob command before to move the files.

See also: How do you move all files (including hidden) in a directory to another?

0

I realize this is an older question, but the above answer is incorrect about the cause of the problem.

You can rename a folder to a name with slashes in it, as long as it's a valid path to somewhere.

What you cannot do is rename . because your current location in the shell becomes invalid if you do so and the shell avoids creating this situation.

The suggestion of moving the contents rather than folder works, or you can move to the parent folder and do the move from there:

cd ..
# Now we are one level up, so one less ../
mv your-original-subdirs-name ../GuardDog-CMS

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .