Invalid argument argument when moving files

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

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?

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like