Results 1 to 7 of 7

Thread: [SOLVED] Terminal access to File attributes

  1. #1
    Join Date
    Apr 2008
    Beans
    89

    [SOLVED] Terminal access to File attributes

    I need a way to determine the number of pages of a pdf by running a command in the terminal. If I right click the file and go to properties>Document, I can see how many pages there are but I need a script to automatically pass that value as an argument. So, what command does nautilus execute to determine that information?

    Thanks

  2. #2
    Join Date
    Oct 2006
    Location
    Lyon, France
    Beans
    839
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Terminal access to File attributes

    You'll want pdfinfo.
    This is the first age that's paid much attention to the future, which is a little ironic since we may not have one.
    -- Arthur C. Clarke

  3. #3
    Join Date
    Apr 2008
    Beans
    89

    Re: Terminal access to File attributes

    Quote Originally Posted by Mornedhel View Post
    You'll want pdfinfo.
    Thank you.

    Do you perhaps know how to send only the 6th field to stdout?

  4. #4
    Join Date
    Apr 2008
    Beans
    89

    Re: Terminal access to File attributes

    Oh, wait.

    pdfinfo file.pdf | grep Pages.

    but then how do I get Only the value 2, or whatever the number is?

  5. #5
    Join Date
    Oct 2006
    Location
    Lyon, France
    Beans
    839
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Terminal access to File attributes

    pdfinfo your_document.pdf | grep Pages will output something like

    "Pages : 357"

    If you want only the 357 to show, you will need a bit of sed :

    pdfinfo your_document.pdf | grep Pages | sed 's/[^0-9]*//g'
    This is the first age that's paid much attention to the future, which is a little ironic since we may not have one.
    -- Arthur C. Clarke

  6. #6
    Join Date
    Apr 2008
    Beans
    89

    Re: Terminal access to File attributes

    Quote Originally Posted by Mornedhel View Post
    pdfinfo your_document.pdf | grep Pages will output something like

    "Pages : 357"

    If you want only the 357 to show, you will need a bit of sed. I'm afraid I need to read up on sed myself...
    You have helped immensely, thank you!

  7. #7
    Join Date
    Oct 2006
    Location
    Lyon, France
    Beans
    839
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: [SOLVED] Terminal access to File attributes

    Sorry, I edited my above reply but you were too quick.
    This is the first age that's paid much attention to the future, which is a little ironic since we may not have one.
    -- Arthur C. Clarke

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •