Entering edit mode
3.4 years ago
mathavanbioinfo
▴
80
Dear All
I have list of thousand folder containing files in sub folder and sub-sub folder. I want to transfer all the files only into another folder. Is there any way to do it command line.
I agree with Vincent, this question is more of a linux admin question, and since I'm not a linux admin I don't have the best answer. I can't think of a simple one-liner, but a sample shell script could do it:
I'm not sure what you mean by "a list of thousand folder"...if all the folders are in one directory, the solution above would work. If they're in various directories in an actual list, you could modify the script above by assigning your list to a variable and looping over it to recursively find files before getting their basename so you can move them. This solution assumes that none of the files will clash (they must all have unique names, otherwise you'll be writing files over each other).
Why the loop though?
find -exec
should do the job. Something like this should suffice:Ha ha :) that would be the "I don't know the best answer" part of my answer. I didn't know about the exec option for find, and if the OP really does have a list of directories (in a file), he could convert that to a shell script. I've certainly dealt with messy unwieldy detritus from an analysis that had no easy answer.
Hi Mathavan - a post like this is best addressed to forum like stack overflow. However, for this post there is no need to create a new post. You can read the man page for mv, or you can google the question. I found this post: https://unix.stackexchange.com/questions/67503/move-all-files-with-a-certain-extension-from-multiple-subdirectories-into-one-di
They'd downvote the question and close it over at
Stack Overflow
. It's just not sufficiently programming related. The forum you linked to--theUnix StackExchange
--is where this question should be asked IMHO.That is why I wrote "there is no need to create a new post. You can read the man page for mv, or you can google the question. I found this post:" etc...
Apologies Vincent Laufer , I had overlooked that part. Thank you for pointing that out. I did not mean to be snarky or something.