LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   show/edit txt file metadata (http://www.linuxquestions.org/questions/linux-general-1/show-edit-txt-file-metadata-4175456868/)

porphyry5 04-04-2013 01:03 PM

show/edit txt file metadata
 
How can I show and edit the metadata of txt format ebooks in linux? I can do what I need with calibre, but I want to automate the process with command line utilities instead

gangadhar402 04-05-2013 11:48 PM

Hi,

write a simple script with following
wget - to down load the html of url

strstr()-search a string (metadada) in that file

you will also try with curl

will help you

porphyry5 04-06-2013 12:41 PM

Quote:

Originally Posted by gangadhar402 (Post 4926072)
Hi,

write a simple script with following
wget - to down load the html of url

strstr()-search a string (metadada) in that file

you will also try with curl

will help you

You lost me at wget, for many of these files there is no url to download that I'm aware of.

Calibre will create the minimum necessary metadata for them (all I actually have to do is supply calibre with the author name), without any connection to the net.

I believe this added metadata is inserted in the txt files headers by calibre, because:
if I pass the unmodified txt files to my ereader, it organizes them in its database by filename and modification date, which is not very useful for me;
but if I add the author name to these txt files using calibre's Metadata Edit process and then pass just the modified txt files to my ereader, its database now makes files available by filename, author or modification date.

This information is not contained in the body of the txt file concerned. The only place it can be is in the file header, so all I'm actually seeking is a command line tool that will show and edit the content of file headers.

gangadhar402 04-08-2013 07:02 AM

hi,

from the command line I did not tried this one ...
but it's quit easy with simple code, it's easy to extract any thing from files.........

do you have links for that files,then I can see those files.In past,I had some experience with these metatags.that time I was written code based on wget and some string functions .....

we can extract any thing from that file by using simple scripts ....
you need not require wget here...
because you already have those files with you ...

inside of the code
use fopen() /open()
read the file by character by character..
search for what ever you want ...

like
author name,
last revised,
and what ever you want ..

so that you can able to show them and also you can able to edit

porphyry5 04-08-2013 12:50 PM

Quote:

Originally Posted by gangadhar402 (Post 4927485)
hi,

from the command line I did not tried this one ...
but it's quit easy with simple code, it's easy to extract any thing from files.........

do you have links for that files,then I can see those files.In past,I had some experience with these metatags.that time I was written code based on wget and some string functions .....

we can extract any thing from that file by using simple scripts ....
you need not require wget here...
because you already have those files with you ...

inside of the code
use fopen() /open()
read the file by character by character..
search for what ever you want ...

like
author name,
last revised,
and what ever you want ..

so that you can able to show them and also you can able to edit

We seem to be talking at cross purposes. What scripting language are you referring to? Neither open nor fopen exist in bash, the only scripting language I am familiar with. Nothing I know of, not even hex editors like bpe, actually show the file header. touch can modify certain content in the header but does not show its layout.

Diantre 04-09-2013 12:45 PM

Quote:

Originally Posted by porphyry5 (Post 4926402)
I believe this added metadata is inserted in the txt files headers by calibre, because:
if I pass the unmodified txt files to my ereader, it organizes them in its database by filename and modification date, which is not very useful for me;
but if I add the author name to these txt files using calibre's Metadata Edit process and then pass just the modified txt files to my ereader, its database now makes files available by filename, author or modification date.

I'm under the impression that your ereader is using the filename of the text files to do the sorting, since Calibre will rename any file you add to its database based on the author and title provided.

Quote:

Originally Posted by porphyry5 (Post 4926402)
This information is not contained in the body of the txt file concerned. The only place it can be is in the file header, so all I'm actually seeking is a command line tool that will show and edit the content of file headers.

AFAIK, text files do not have any metadata nor header, they're just plain text.

porphyry5 04-09-2013 01:41 PM

Quote:

Originally Posted by Diantre (Post 4928324)
I'm under the impression that your ereader is using the filename of the text files to do the sorting, since Calibre will rename any file you add to its database based on the author and title provided.

Correct, but some text files that I obtained from Project Gutenberg are not accepted by Calibre at all, it will not add them to its library, giving the error message "Failed to read metadata from the following ..." Other text files it makes no objection to.

Quote:

Originally Posted by Diantre (Post 4928324)
AFAIK, text files do not have any metadata nor header, they're just plain text.

Every file has a header of some sort, with at least access, modification and creation dates, size data etc. But I think you are correct about text files having no metadata. Examining what is actually on my ereader with ls, rather than what the ereader claims is there, reveals the presence of 2 files, metadata.calibre and driveinfo.calibre. If I remove them, the reader reverts to file name only organization of its data base.

But as it turns out, as all I wanted was to have the files organized by file name within author, the simplest way of achieving that effect was to rename the files, making the author name the first part of every file name. That way I get the desired effect with just the data base organized by file name. So I'm marking this thread as solved even though Ive not got the original question answered. I thank you all for your help.


All times are GMT -5. The time now is 01:08 AM.