File extraction

Not really a Linux question as such but file management and would be the same question on Windows or Mac.

I have a hard disk with folders, sub folders, and sub sub folders, then documents. Structured but each one is different. At the bottom level I have files which I would like to extract and put all together, not in the folders so I can transfer them without the structure.

So for example
John has 1 document
Fred has 2 folders history and fiction with documents inside
Mike has 3 folders fiction non fiction science and in each there are files, sometimes 1 file some times 2 or 3

They are all different file names but are .mobi (for kindle)

There are around 2500 folders so Linux tells me on the disk

I am using Linux mint 19.1 32 bit on Apple MacBook pro, and the disk external is connected by usb. I can transfer them to the internal disk. They are going on to my kindle in the end to read but not all in one go as too many.

This is a real question and not school homework, and please don’t as where they came from or say buy on Amazon to pay for the books as they are just not available from that source.

Did this once before but took days and manually so not ideal. Cannot ask Google too complex question
Thanks

1 Like

Geeky as hell!
d55
Thanks.

1 Like

Thanks for that, not yet had chance to try it but hope to in next few days
Had looked at the ebook application calibre which appeared to do it graphically but last stage of extraction not correct

The following might give you a start - I have achieved the task you are trying to do fairly easily in Windows but the principles should hold for Linux too.
I used a File Search program, such as Agent Ransack and searched for all files that matched a particular pattern, say *.mobi. Then I highlighted every file in the search result list and copied them to my destination. This copied all the files and ignored the directory structure.
You will have to experiment a little to find a File Search program in Linux that does the same thing, but Nautilus or Nemo might give the results you want. It will only take you 5 minutes to try it.
Back in the MS-DOS days the XCOPY command had a switch that would do this too. XCOPY was a fabulous, and much under-used CLI command.

1 Like

Not a bad idea, however here were are talking about thousands of files. You should avoid unnecessary overhead (like a GUI) when performance is critical.

Thanks for the ideas
Never used xcopy in my dos days so cannot remember
Tried the subjection from akito last night but no luck, did not appear to do anything under any form of playing
Calibra found my files and allows me to select them in the find, so I know there are over 5500 of the mobi type, plus a few others of ebook style which I can use to convert
It does have an extraction copy to or save as options. But simply copies the structure as well so not really extraction.
Will have a go with the search in the file manager later on and report back
Thanks again

Can you elaborate on that?

Some times the answers are just so easy … you fail to see them. And in my case I failed to see the search option in the file manager as it’s a menu choice not an icon.
So selected folder,
selected find, .mobi files
It looks at subdirectories
copy and paste into new folder
Job done
Much easier after the suggestion of jrmwalsh . Thanks

Sorry cannot give more detail on why it failed
No screen message just ran the program and nothing
But thanks for the help and trying
In the end the simple solution of search which I had not tried worked
Next time I need to rtfm !
Cheers

I tested the script and it is working.

Run it like this:

bash move_mobi.sh /path/to/backup