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?


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
| improve this answer | |
  • Good point, but I think under Mac OS it will be cp -R (upper case R). – QSQ Oct 2 '12 at 21:51
  • @QSQ Thanks for the correction. Fixed it now. – Ryan Oct 2 '12 at 21:55
  • -r worked fine. – Andrew D. Oct 2 '12 at 23:17
mv scenery/terrain/*/terrain/* scenery/terrain/
mv scenery/terrain/*/objects/* scenery/objects/
| improve this answer | |
  • Try it on a copy of the folder in case I misunderstood something :-) – QSQ Oct 2 '12 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 '12 at 21:15
  • Didn't work. Says that "directory is not empty" – Andrew D. Oct 2 '12 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 '12 at 21:24
  • Maybe I can try to move the current /terrain dir somewhere else to prevent file conflicts? – Andrew D. Oct 2 '12 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.