View Single Post
Old 07-25-2007, 11:36 PM   #1
coleman
Connoisseur
coleman began at the beginning.
 
Posts: 95
Karma: 38
Join Date: Jul 2007
Device: Android tablets and phones, Windows tablet, Kobo Aura One
Would anyone be interested in this script...

So I haven't received my reader yet, but I'm already preparing for it.

I hope I didn't just do something that someone else already did, but I wrote a script today that acting as a wrapper to the various 2lrf programs, which allows you to easily batch process a large number of files which have things that you'd want in metadata, in their file names. e.g.
Say I have these files:
Bob, Smith - Bob's Books - Book 1.txt
Bob, Smith - Bob's Books - Book 2.txt
Bob, Smith - Bob's Books - Book 3.txt
Jones, Sam - Sam's Books - Book 1.lit
Jones, Sam - Sam's Books - Book 2.lit

using my script, you can say:
File2LRF "Bob, Smith - Bob's Books - Book 1.txt" a,t,s

The script will deconstruct the file name, identify what type it is based on the extension, then call txt2lrf(in this case, it will work with lit, rtf, and htm/html), and add the metadata fields for the author and title.

The "a,t,s" stands for author, title, and subtitle. You're just describing where each token is in the file name, so if the author had been last, it would read, "t,s,a" instead.

Ok...now, that in of itself isn't that great of a time saver, but what you can then do(I was too lazy to add file name support directly in the script) is use the FOR command with the wrapper to process a bunch of files that have the same general token layout, and end up with LRF files that have meta data in them, i.e. to do all 3 of those(or any arbitrary number as long as the token layout is the same) I could then do this at the command prompt:

FOR %x IN (BOB*.*) DO File2LRF "%x" a,t,s

and that would process all 3 of the Bob files. Now, the extra cool part, since the Sam files in the example have the same token structure, i.e. author, followed by title, followed by subtitle, in my FOR, I could have specified *.* as the file spec, and it would work on all 5 files.

So it's important you choose the wildcard spec in the FOR carefully, because all the files that match it MUST meet the token spec. If they don't, you'll either get weird broken behavior at worst, or at best, you'll get a file, but it'll have metadata in the wrong spots. You could do a whole directory at once as long as the file names are all structured the same. The script will ignore/discard files with extensions it doesn't have a way to handle(i.e. PDF right now).

Let's see...that's everything, it's not thoroughly tested, but a couple of tries on my own stuff and it seems to work. If it would be helpful to anyone else, let me know and we can arrange for you to get a copy, or if there's enough interest I'll put it up somewhere.

Maybe libprs500 had an easy way to do this, but I didn't find it if it did.
coleman is offline   Reply With Quote