5

Using evince I bookmarked a pdf file (in ubuntu 16.04). I want to copy these evince's bookmarks. I found they are stored as metadata and can see them using

gvfs-info myfile.pdf

But I found no way to "paste" these bookmarks to the file metadata, if I copy it to another location or another computer. Found the same problem here with a suggestion (cp --preserve=all) that does not work.

(I mostly use ubuntu 16.04 with cinnamon but I also have some installations with versions of Mint.)

1
2

The answer you linked to was wrong - not even remotely close to correct. The attributes preserved by cp are ONLY filesystem attributes (ownership, timestamps, permissions). file metadata is completely unrelated.

There isn't any easy way to copy application-specific data like evince's bookmarks to another system. The bookmarks aren't stored IN or with the file, they're stored by evince using GIO.

You could extract the metadata with gio info, store it in a file, and then restore it on the remote system. For example, if using scp to copy the file on the remote host:

gio info -a "metadata::evince::bookmarks" filename.pdf  | 
  sed -n '/metadata::/ s/^.*: //p' > filename.bookmarks

scp filename.pdf filename.bookmarks user@remote:/path/to/store/file/

Then, on the remote system:

cd /path/to/store/file/
gio set filename.pdf 'metadata::evince::bookmarks' "$(cat filename.bookmarks)"

BTW, variations of this method can probably also be used to restore GIO metadata to files if you've used standard unix tools (like cp or mv) to copy or move the files around, rather than staying within GIO-aware applications like nautilus

3
  • 1
    Note: as is usual for Gnome software, the documentation is abysmal - at best it's barely adequate as reference material, but there are no explanations or examples of anything. You have to figure this stuff out by trial-and-error, and even if you get something that works, it still feels like voodoo, or like fragile guesswork that will break when they decide to come up with a shiny new registry clone. Writing scripts like this wouldn't be necessary if their file browser nautilus had readily accessible options to export GIO data related to a file AND to import such data from a file. – cas Dec 30 '17 at 7:16
  • the problem arise in multiple situations such as mailing the pdf (ex. to me), pdf read from different OS'es in the same computer (using multiple boots or on a shared folder for vitual box etc.). gio is not in ubuntu repositories so I cannot verify the solution – ilias iliadis Jan 1 '18 at 17:29
  • try gvfs-info and gvfs-set-attribute. they're the old versions of the commands, now subsumed into gio (on my debian sid boxes, they still exist as sh wrappers calling gio info and gio set - after first displaying a message like "This tool has been deprecated, use 'gio info' instead.") – cas Jan 2 '18 at 4:08
0

Thanks a lot cas. Used: gvfs-info -a metadata::evince::bookmarks: myold.pdf

then:

gvfs-set-attribute -t string mycopied.pdf metadata::evince::bookmarks "extracteddataenclosedindoublequotes"

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.