Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made a mistake in a rsync and all the files are copied long with its full path. All the files that I copied are at


Attempt 1

Now I would like to fix the paths, by doing

 mv /var/www/photos/2012/1007/1007 /var/www/photos/2012

This gives the error:

mv: cannot move `/var/www/photos/2012/1007/1007' to `/var/www/photos/2012/1007': Directory not empty

Attempt 2

 mv /var/www/photos/2012/1007/1007/* /var/www/photos/2012/1007

I get the error:

-bash: /bin/mv: Argument list too long

Question: What will be the correct way to rename the folder that contains alot of files?

The files were actually copied to /var/www/photos/2012/1007/home/photos/public_html/2012/1007 but somehow I got them to /var/www/photos/2012/1007/1007

Rsync cmd:

rsync -zavrR --rsh="ssh -c arcfour -l root -p 2200" /var/www/photos/2012/1007

share|improve this question
up vote 2 down vote accepted

This worked in my test with the paths you gave:

cd /var/www/photos
mv 2012 old
mv old/1007/1007 .
mv 1007 2012

What's happening is you are trying to move a directory over top of an existing directory - and it doesn't like doing that because there's stuff in the directory. By renaming 2012 first, you can move it without problems.

share|improve this answer
Awesome!!!! Will need to mv old 2012 before mv 1007 2012. Thanks! – Nyxynyx Oct 11 '12 at 18:02

At least two ways I can think of:

1: First rename /var/www/photos/2012/1007 to /var/www/photos/2012/temppath, then mv /var/www/photos/2012/temppath/1007 -> /var/www/photos/2012/, then rmdir /var/www/photos/2012/temppath.

2: Use a simple script to move the contents:

for f in `find /var/www/photos/2012/1007/1007 -mindepth 1`; do mv $f /var/www/photos/2012/1007/1007/../; done

First method it probably a better answer to your question.

share|improve this answer
Too late I was... – por Oct 11 '12 at 18:05
Thanks! ~~~~~~~ – Nyxynyx Oct 11 '12 at 18:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.