Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I downloaded a rather large filestructure (>100GB) to a subfolder of my root directory, lets call it /folder. The problem is, I accidentally copied it into a subfolder of that folder, rather than just directly into that folder, so now I have /folder/folder/* instead of /folder/* which is what I want. Is there a better way to remove the extra level than just:

# mv /folder/folder/* /folder
# rmdir /folder/folder
share|improve this question

4 Answers 4

up vote 5 down vote accepted

If source an destination are on the same filesystem, mv will just create another directory entry, it will no copy 100 GB of data. So this is the best way to do it, you don't need to search for another way. But if they are on different filesystems, the data will be copied. Also, you don't need to rmdir - mv will do that automatically.

share|improve this answer
    
It won't remove the directory automatically in this case since the folder itself is not being moved. Clearer example: mv /folder1/folder2/* /folder1 - now you still have folder2 left, though it is empty. –  Daniel Andersson May 10 '12 at 7:44

The mv command doesn't move the data in the files, just the names of the files. If you are worried about all of the data in every file being moved, this won't do it.

share|improve this answer

You can use:

# cd /folder/folder
# mv * ../
# rmdir /folder/folder

but what is the problem with what you had? Can you clarify what you mean by a better way?

share|improve this answer

A slightly simpler procedure (fewer overall mv operations)

  mv /folder /surplusfolder
  mv /surplusfolder/folder /folder
  rmdir /surplusfolder
share|improve this answer

Your Answer

 
discard

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.