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?
-
You need to be more specific about what you want to do, maybe provide an example of what you would like.– PeltierApr 21, 2011 at 18:07
-
What should happen with the .foo folders when the rest is being moved?– LesmanaApr 21, 2011 at 18:09
-
The .foo folders can either be removed or left alone. It doesn't matter which.– Random255Apr 21, 2011 at 18:50
Add a comment
|
1 Answer
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.