22

I have folders in scenery/terrain that contain folders called terrain and objects. These folders have folders with data files. How do I move all of the contents scenery/terrain/[name]/terrain to scenery/terrain, and the contents of scenery/terrain/[name]/objects to scenery/objects?

2 Answers 2

28

There is no recursive option for the mv command, so if there are directories inside the directories you want to move, you'll have to use cp. How about this one:

cp -R scenery/terrain/*/terrain/* scenery/terrain/
cp -R scenery/terrain/*/objects/* scenery/objects/

Then when you're sure that worked:

rm -rf scenery/terrain/*/terrain
rm -rf scenery/terrain/*/objects
4
  • Good point, but I think under Mac OS it will be cp -R (upper case R).
    – QSQ
    Oct 2, 2012 at 21:51
  • @QSQ Thanks for the correction. Fixed it now.
    – Ryan
    Oct 2, 2012 at 21:55
  • -r worked fine.
    – Andrew D.
    Oct 2, 2012 at 23:17
  • WTF are you guys talking about? mv my-app dev/my-app will recursively move all content of my-app to the dev/my-app. Which means mv is recursive by default. Aug 30, 2021 at 20:15
1
mv scenery/terrain/*/terrain/* scenery/terrain/
mv scenery/terrain/*/objects/* scenery/objects/
9
  • Try it on a copy of the folder in case I misunderstood something :-)
    – QSQ
    Oct 2, 2012 at 21:14
  • Too late now.. Fail on my part. I can always just re-torrent the 13 GB of scenery.
    – Andrew D.
    Oct 2, 2012 at 21:15
  • Didn't work. Says that "directory is not empty"
    – Andrew D.
    Oct 2, 2012 at 21:16
  • Hmm odd. I had tried it here with building a tree like that and putting files into scenery/terrain/a/terrain/ scenery/terrain/b/terrain/ and scenery/terrain/a/objects/ and scenery/terrain/b/objects/
    – QSQ
    Oct 2, 2012 at 21:24
  • Maybe I can try to move the current /terrain dir somewhere else to prevent file conflicts?
    – Andrew D.
    Oct 2, 2012 at 21:28

You must log in to answer this question.

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