1

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?

3
  • You need to be more specific about what you want to do, maybe provide an example of what you would like.
    – Peltier
    Apr 21, 2011 at 18:07
  • What should happen with the .foo folders when the rest is being moved?
    – Lesmana
    Apr 21, 2011 at 18:09
  • The .foo folders can either be removed or left alone. It doesn't matter which.
    – Random255
    Apr 21, 2011 at 18:50

1 Answer 1

1

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.

You must log in to answer this question.

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