LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-04-2013, 01:03 PM   #1
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch
Posts: 421

Rep: Reputation: 18
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
 
Old 04-05-2013, 11:48 PM   #2
gangadhar402
Member
 
Registered: Mar 2013
Location: the India
Distribution: Ubuntu,Debian and CentOS
Posts: 35

Rep: Reputation: 2
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
 
1 members found this post helpful.
Old 04-06-2013, 12:41 PM   #3
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch
Posts: 421

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by gangadhar402 View Post
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.
 
Old 04-08-2013, 07:02 AM   #4
gangadhar402
Member
 
Registered: Mar 2013
Location: the India
Distribution: Ubuntu,Debian and CentOS
Posts: 35

Rep: Reputation: 2
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

Last edited by gangadhar402; 04-08-2013 at 07:06 AM.
 
Old 04-08-2013, 12:50 PM   #5
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch
Posts: 421

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by gangadhar402 View Post
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.
 
Old 04-09-2013, 12:45 PM   #6
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 390

Rep: Reputation: 150Reputation: 150
Quote:
Originally Posted by porphyry5 View Post
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 View Post
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.
 
Old 04-09-2013, 01:41 PM   #7
porphyry5
Member
 
Registered: Jul 2010
Location: oregon usa
Distribution: Slackware 14.1, Arch
Posts: 421

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by Diantre View Post
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 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use Shell script to edit a data at a particular location in a txt file? leena_d Programming 30 02-08-2010 12:43 AM
How can I use Shell script to edit row 23 column 5-8 in a txt file? leena_d Linux - Newbie 4 12-14-2009 03:43 AM
LXer: vimdiff - Edit two or Three versions of a file with Vim and show differences LXer Syndicated Linux News 0 04-09-2009 12:21 AM
Edit txt file imkornhulio Programming 6 01-22-2009 05:36 PM
how to edit a txt file through console safrout Linux - Newbie 5 01-31-2003 07:39 PM


All times are GMT -5. The time now is 11:56 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration