Suppose, I download a book from a URL(using wget or other tool). I want to save the book and the URL, so that I can know from where I downloaded the book.

I don't use different file. I want to save the URL inside the book file(may as one attribute of the book file).

  • 2
    TO store it inside the file we need to know the file format of the book (pdf?). Then you could use tools to add meta information to that format. Easier and universal approach: How about adding the URL to the file name? – Philippos May 15 '17 at 7:09
  • It depends on the book format: If the book is in epub format, for example, it's just a zip file, so you can echo the URL from wget into a file, and add this file to the epub book file. You can also add it as a HTML comment to the opf file inside the epub. – dirkt May 15 '17 at 8:25

Would something like a log file work:

wget -nv -o wget.log -O "save-file" "URL" 

And if you want to keep adding to the log file instead of overwriting it:

wget -nv -a wget.log -O "save-file" "URL"

What you get is something like:

2017-05-15 16:46:58 URL:https://some.url/ [file size] -> "save-file" [1]

What is happening here:

-nv : "not verbose" output. Just the details, not everything.

-a wget.log : "append" info to the log file (in this case, "wget.log").

-o wget.log : Creates a new log file (old one is removed, if found).

The rest you most likely know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.