View Full Version : Easist way to modify IMP books internal header info?


askyn
09-24-2008, 01:17 AM
Hi all ( ill bet you all are getting tired of seeing my posts by this point )

I have another question for those that have gone thru all this before.

What is the easist way to edit a IMP file to change the author / title / catagory information?

WITHOUT using ebookwise librarian. ( If install it after epub and all the other addons etc things get messed up )

Just looking for a quick and easy way, mainly so I can change / add the catagory field on books so that they are sort on the 1150 the way id like.

Thank you.

nrapallo
09-24-2008, 01:43 AM
EDIT: I've now written a little dos command line utility in Perl called impmeta available here (http://www.mobileread.com/forums/showthread.php?p=421533#post421533).

In our wiki pages, you will find IMP software, which listsImp Librarian (http://www.mobileread.com/forums/showthread.php?t=23003) - windows - to catalog a collection of .IMP files and produce .csv files for import into MS Excel or equiv.

With it you can edit selected .IMPs (I found some files edited by Imp Librarian that could not be edited properly afterwards with GEBLibrarian - use with extreme caution & use on backups until you're sure this works for you!)

Also, I've been meaning to write an impedit utility for some time now (EDIT: see above), but have been distracted writing plugins for some program here :smack:). It would be written in perl and have a similiar GUI interface to Mobi2IMP/PDFRead. (btw, that GUI was the brain child of ashkulz; I just copied it!)

In essence, the .imp ebook has fields after the first 48 bytes that are null byte terminated (dot represents that 0 byte):ID . Category . Subcategory . Title . LAuthorname . MAuthorname . FAuthorname .
The only problem editing these directly with a hex/binary editor is that if the length changes for any field, the size of this header record in the imp file must be recalculated along with the offset to the .RES TOC entries. Not hard, but will take some time to code and perfect. I'll look at this soon, if ashkulz doesn't beat me to the punch. :fingersx:

For more information, see IMP and the detailed reverse-engineering work done by Jeffrey Kraus-yao in 2002 here (http://krausyaoj.tripod.com/reb1200.htm).

If you promise to not get tired asking questions, I promise to not get tired answering them... :2thumbsup

askyn
09-24-2008, 02:23 AM
If you promise to not get tired asking questions, I promise to not get tired answering them... :2thumbsup

Thans not a problem, im sure ill have more questions then answers for a long time.

ashkulz
09-24-2008, 02:24 AM
Looks like I'll have to add a new command-line utility called 'impmeta' to ebookutils ... expect to see it in a release tomorrow.

askyn
09-24-2008, 04:02 AM
Looks like I'll have to add a new command-line utility called 'impmeta' to ebookutils ... expect to see it in a release tomorrow.

cool .. with maybe a gui wrapper in the future? ( hey a guy can wish cannt he ? )

woot =)

ashkulz
09-24-2008, 06:09 AM
cool .. with maybe a gui wrapper in the future? ( hey a guy can wish cannt he ? )don't look for a GUI wrapper from me ... if you want to contribute one, I'm willing to integrate it ;)

derrell
09-24-2008, 09:56 AM
It wouldn't be too hard to add impmeta to the list of things that the gui I've been tinkering with can call. It is just a front end for several other tools anyway.

nrapallo
09-24-2008, 09:58 AM
Looks like I'll have to add a new command-line utility called 'impmeta' to ebookutils ... expect to see it in a release tomorrow.

It should also allow the name of the .RES directory (and thus its length) to be changed; as a default, use the filename.

I have so many Lit2sb .imp conversions that ALL have 'o_sb' as their .RES directory name. This is the name you see (given) to the folder that gets exploded on the memory card! I can never find which 'o_sb' is the one I'm looking for. :smack:

The reader's internal os allows idential mutiple names and the only way to differentiate them is to look at the RSRC.INF; yeah, right, like I'm going to do that for 100+ titles... :angry:

nrapallo
09-24-2008, 10:05 AM
It wouldn't be too hard to add impmeta to the list of things that the gui I've been tinkering with can call. It is just a front end for several other tools anyway.

I have some perl code that extracts the header info and stuff but doesn't allow the meta data to be edited via GUI. I can give you the starting point, if you would finish it off.

email me at 'nrapallo (at) yahoo (dot) ca'

ashkulz
09-24-2008, 10:30 AM
It wouldn't be too hard to add impmeta to the list of things that the gui I've been tinkering with can call. It is just a front end for several other tools anyway. Do you have any plans of releasing the GUI in the near future? I'd prefer to delay the 0.9 release to include that ... maybe even call it 1.0 :)

BTW, were you able to get the browsing under linux using eb1150 working? it worked for me with the later versions....

derrell
09-24-2008, 10:54 AM
The gui is the one that I've working with for impfind. It sort of grew past just displaying imp files. It has some basic bookshelf management and will search for imp, lrf, mobi, zipped oeb and html books as well as epub and display some of the meta data for all of them. I need to change the name to something other than impfind now. As for releasing I'm in no hurry what I have now needs some serious cleaning up and I'm not real sure it will work under windows anymore. So waiting for the next release of ebook utils is not a problem.

As for the browsing haven't tried it yet with the newer versions. I think I'm still using 0.4. So I'm just a little behind the times.

askyn
09-24-2008, 11:49 AM
Ill be waiting excitedly for these utilities for sure.

im not SURE its ImpLibrarian, but after using it to edit information on a selected batch of imp files, I dont seem to be able to load those files onto my 1150 ! ( for those intersted see the posting I made this morning (9/24/09) under impserv)

Not sure if its a problem with imp librarian or something that its done that imserv doesnt like etc.

so ill have to keep looking for a alternate way to edit that information.

thanks for all the help and suggestions tho!

nrapallo
09-24-2008, 11:59 AM
Ill be waiting excitedly for these utilities for sure.

im not SURE its ImpLibrarian, but after using it to edit information on a selected batch of imp files, I dont seem to be able to load those files onto my 1150 ! ( for those intersted see the posting I made this morning (9/24/09) )

Not sure if its a problem with imp librarian or something that its done that imserv doesnt like etc.

so ill have to keep looking for a alternate way to edit that information.

thanks for all the help and suggestions tho!

It may be that Imp Librarian fails to recalculate the revised size of the fields header. Can you try editing a .imp using the same *length* for the fields, i.e. don't add/delete any letters, just replace existing ones.

I suspect that for this case it WILL work and maybe that's why Imp Librarian may work for some files.

askyn
09-24-2008, 12:09 PM
ROFL ok.. imp librarian is way flaky and im going to drop using it for now.

reason?

It wont even open the shelf directory now were the imp files it edited last night are at !!

errors out with the error:

Runtime error '5'; invalid procedure call or argument

considering the only thing ive done with the books in that directory is a) copy them there b) edited them with imp librarian .. then c) tried to load them

I think imp librarian is a great concept program but has a few bugs.

GeneS
09-24-2008, 01:07 PM
ROFL ok.. imp librarian is way flaky and im going to drop using it for now.

reason?

It wont even open the shelf directory now were the imp files it edited last night are at !!

errors out with the error:

Runtime error '5'; invalid procedure call or argument

considering the only thing ive done with the books in that directory is a) copy them there b) edited them with imp librarian .. then c) tried to load them

I think imp librarian is a great concept program but has a few bugs.

Askyn and I seem to be running into each other in a number of threads.

I have not experienced any trouble seeing, transferring, or using .imp files that have been modified by ImpLibrarian. I am, however, going to stop using it in light of Askyn's experience.

I really do hope for a way (GUI?) to modify the header data so that I can quickly find a book once it's on my 1150. Thanks to those of you who have the knowledge and interest to work on making the 1150 more useable.

shighfield
04-07-2009, 11:40 AM
Nick: Any work on impedit yet? I'm looking for a way to edit the catagory in an IMP file from the command line.

nrapallo
04-07-2009, 11:54 AM
:whistle: I haven't written it yet...

But I do remember helping AZed add that capability to EBook-Tools (http://www.mobileread.com/forums/showthread.php?t=31142) on CPAN (Perl code repository).

I'll see if I can use AZed's code to create a functional 'impedit' command line program, but I know a GUI solution that works quite well, ConvertIMP (http://www.mobileread.com/forums/showthread.php?t=34548). ;)

What target program would you prefer to use: Windows executable or Unix/MAC Perl script? Any syntax you would like to see used for the option/parameter switches?

shighfield
04-07-2009, 12:56 PM
I am using windows now so a windows .exe is the best for me. Syntax doesn't matter at all, I'm learning some python and am determined to find a way to hack this stuff into Calibre. Hence why I need commandline tools for everything.

I know it won't be part of the main calibre tree but I'm hopful I can get it working enough for Windows users to be able to muck with.

nrapallo
04-07-2009, 06:29 PM
I am using windows now so a windows .exe is the best for me. Syntax doesn't matter at all, I'm learning some python and am determined to find a way to hack this stuff into Calibre. Hence why I need commandline tools for everything.

I know it won't be part of the main calibre tree but I'm hopful I can get it working enough for Windows users to be able to muck with.

Ooohhhh, calibre hacking... ;)

Here is a quick and dirty attempt at a .imp metadata edit program called impmeta. It is based on ebook.pl from EBook-Tools by Zed Pobre. The readme for it is as follows: impmeta - Set specific metadata values in an ETI .imp file.

Usage:
impmeta filename.imp [Options]

Options:
--input filename.imp | -i filename.imp
Specify the input filename. This can also be specified as the first argument, in which case the -i option will be ignored.

--output modified.imp | -o modified.imp
Specify the output filename. If not specified, the input file will be overwritten.

--identifier
Specify the identifier metadata.

--category | --cat | --c
Specify the category metadata.

--subcategory | --subcat
Specify the subcategory metadata.

--title | --t
Specify the title metadata.

--lastname
Specify the author last name metadata.

--middlename
Specify the author middle name metadata.

--firstname | --author | --a
Specify the author first name metadata. Note that IMP files commonly place the full name in this component, and leave the middlename and lastname entries blank.

Examples
impmeta mybook.imp --title 'Fixed Title' --author 'John Q. Brandy'
impmeta -i mybook.imp -o fixed.imp --title 'Fixed Title' --cat "To Read"


Try it out first on some backups, and then when you sure it works for you, go live...

Anything you can think of that's missing or you want added?

shighfield
04-07-2009, 08:13 PM
Nick: That works great! I've only really tested the catagory part, but will beat this up for you as I'm converting a ton of books from LRF to HTML / IMP now.

Additions... What about a way to mass change a directory? ie: impmeta *.imp --cat "Fantasy" would set the whole shebang in the directory?

My end goal is to (under windows for now) click a button and be able to edit fields in IMP's from calibre, convert to IMP within calibre, etc.

nrapallo
04-07-2009, 08:49 PM
Nick: That works great! I've only really tested the catagory part, but will beat this up for you as I'm converting a ton of books from LRF to HTML / IMP now.

Additions... What about a way to mass change a directory? ie: impmeta *.imp --cat "Fantasy" would set the whole shebang in the directory?

My end goal is to (under windows for now) click a button and be able to edit fields in IMP's from calibre, convert to IMP within calibre, etc.

That's easy, using windows for command, place this in a batch file and pass it parameters --cat "Fantasy" (or %1 %2) etc:for %%i in (*.imp) do impmeta "%%i" --cat "Fantasy"


If you execute this at the dos prompt without batch files, then use single % in place of the double %%.

Oh, and for recursively down into all subdirs, use:for /r %%i in (*.imp) do impmeta "%%i" --cat "Fantasy"

:cool:

shighfield
04-08-2009, 09:21 AM
Well then! I always forget about the old command.com tricks. So far I've used it on around 20 books in my real library and all is fine. When I'm out today I'm picking up my first pbook in a long time. Determined to learn python now, it looks easy to work with.

nrapallo
04-08-2009, 10:33 AM
Well then! I always forget about the old command.com tricks. So far I've used it on around 20 books in my real library and all is fine. When I'm out today I'm picking up my first pbook in a long time. Determined to learn python now, it looks easy to work with.

I've got a lot of python self-learn type ebooks in .imp format if you want them. I'll have to check if I have a EBW1150 .imp version as most are in REB1200 .imp format.

shighfield
04-09-2009, 11:20 AM
Thanks Nick! Apreciated the links and will be giving this a go over! Something new to play with so we'll see if it sticks in my head or makes it hurt like basic does. ;)