PDA

View Full Version : How to move certain files from a directory



rohan013
March 16th, 2012, 01:53 PM
i want to move all the .epub files from a folder(and all it's sub-folders).What command should i use ???

i know i can use ""mv *.epub destination_folder""
but it won't move files from the sub-folders

Thanks in advance :p

overdrank
March 17th, 2012, 02:00 AM
Hi and welcome, moved and bumped to Absolute Beginner Talk

MG&TL
March 17th, 2012, 02:05 AM
I think something like:



for $files in $(find . -name "*.epub"); do mv $files <folder>; doneI'm sure somebody will correct me in a minute. Use cp rather than mv to be safe.

cortman
March 17th, 2012, 03:15 AM
I think something like:



for $files in $(find . -name ".epub"); do mv $files <folder>; doneI'm sure somebody will correct me in a minute. Use cp rather than mv to be safe.

Rather than correct, let me compliment your nice little script, MG&TL. But if you're using cp anyway you may as well


cp -r *.epub destination_folder

Oddly enough, mv doesn't appear to have a recursive option...

MG&TL
March 17th, 2012, 02:44 PM
Rather than correct, let me compliment your nice little script, MG&TL. But if you're using cp anyway you may as well


cp -r *.epub destination_folderOddly enough, mv doesn't appear to have a recursive option...


Thanks, Cortman. I was under the impression that -r moved directories...nice to know. :)

And nice sticky, btw. ;)

cortman
March 18th, 2012, 04:43 AM
Thanks, Cortman. I was under the impression that -r moved directories...nice to know. :)

And nice sticky, btw. ;)

Thanks, MG&TL! It seems to be growing at a comfortable rate and hopefully is proving useful. Thanks for your recent contribution. :)