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 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
add comment

1 Answer

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
add comment

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.