Super User is a question and answer site for computer enthusiasts and power users. 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 have folder structure, where some of the subfolders have a .foo subfolder inside. I want to move the root folder structure from foldera to folderb. How can I do this?

share|improve this question
    
You need to be more specific about what you want to do, maybe provide an example of what you would like. – Peltier Apr 21 '11 at 18:07
    
What should happen with the .foo folders when the rest is being moved? – lesmana Apr 21 '11 at 18:09
    
The .foo folders can either be removed or left alone. It doesn't matter which. – Random255 Apr 21 '11 at 18:50
up vote 1 down vote accepted

If you can remove the .foo folders then it's simple... simply delete them and then move the whole thing:

find foldera -type d -name .foo -exec rm -rf '{}' \;
mv foldera folderb

If you want to keep the .foo folders then you can move the whole thing and then move only the .foo folders back:

mv foldera folderb
cd folderb
find -type d -name .foo -exec mkdir ../foldera/'{}' -p \;
find -type d -name .foo -exec mv '{}' ../foldera/'{}' \;

Hope this helps.

share|improve this answer

You must log in to answer this question.

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