I have a large number of text files that I have imported into Calibre, and then converted to .mobi format. Within each text file is the title and author's name.

What would be a possible approach to extracting this information, and then adding to the metadata? Would I need to first add metadata to the associated .opf file? Can I use Calibre, or will I need to use something like Visual Basic?

I have a large number of text files that I have imported into Calibre, and then converted to .mobi format. Within each text file is the title and author's name.

What would be a possible approach to extracting this information, and then adding to the metadata? Would I need to first add metadata to the associated .opf file? Can I use Calibre, or will I need to use something like Visual Basic?

Look in the Help file: Command line Interface section (CLI) for what can be done that way (possibly with a BAT file)

One easy way could be to import the text files again, but first rename them using the metadata inside the files. A script or small program would be needed. I assume that the book titles and author is easy to find inside the text files, using grep or something similar?

Yes, Adoby, the title and author could be parsed from the text. So would I add both title and author to the renamed file, then Calibre would use the filename to populate the metadata? Would I use the CLI to do the import?

You don't mention the format of your text files. Make sure you search the web for answers.. I recently had to change meta data on a large number of pdf's and web searches provided several ways of doing this.. from Applescript (I use Mac) to Acrobat Pro to scripts on the web (load the files to web space and run an existing cgi script.).

I know that doesn't apply to your text files.... my only point is to search for existing answers before you spend hours on your own script. My 1500 pdf files were modified in no time. I saved hours and hours of work.