View Single Post
Old 02-18-2012, 01:15 PM   #9
Limey
Junior Member
Limey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with othersLimey plays well with others
 
Posts: 9
Karma: 2831
Join Date: Dec 2011
Device: Kindle
Hi cool thanks. Please note that my intention is not to change ANY of the metadata, or to change the MOBI file at all. Merely to be able to read the title and author of the book from the metadata so I can programmatically rename the file.

Basically I have written a program for my dad that will tidy up and rename the ebooks based on the author folder they're in. But he has many ebooks which are in a miscellaneous folder with just 1 book per author, and not worth the time to manually put these into separate author folder. Since there's no reliable way to get the program to guess the author name and title based on the filename, programmatically examining the MOBI header seemed a good way to handle it.

So far I've just got to the stage where I can stream the array of bytes into my C# program, reading in the first X bytes (usually the header looks to be just over 1024 bytes so I am taking in 2048 to be on the safe side), since obviously we don't need the whole damn book, just the header!

Of course now the challenge is to parse these bytes and establish whereabouts the relevant author name and title can be found. I currently program in Delphi at work but formerly had many years experience with C# and VB, but never really used C++ or Python.

Anyway I will take a look through your code hopefully it will be a helpful documentation of how to parse the codes.

If I get anything up and running I`ll try to make the C# source available in case any other .Net programmers out there are interested.

Many thanks.
Limey is offline   Reply With Quote