Find the answer to your Linux question:
Results 1 to 6 of 6
Hello List, I have about a thousand single page pdfs, and I want to merge them into one. I saw the standard gs and pdf2ps ways, but to do it ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2009
    Location
    India
    Posts
    4

    Merging 1000 pdfs


    Hello List,

    I have about a thousand single page pdfs, and I want to merge them into one. I saw the standard gs and pdf2ps ways, but to do it for 1000 files is tiresome. So is there some neat trick which can do this?

    The files are already numbered from 00000 to 01xxx.

    Spiffworks

  2. #2
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    If you know how to do it on the command line, there has to be a way to script it

    What have you got so far?

  3. #3
    Just Joined!
    Join Date
    Jul 2009
    Location
    India
    Posts
    4
    The thing is, you can just 'cat x.ps y.ps xy.ps'. But I want to do this recursively, and i don't know shell scripting. If you could just point me to a command that can increment filenames, i can do the rest.

    Ok, I tried this. I seem to have made some syntax error, because its not evaluating the find expression. Hence the error.

    ps2pdf 'find /home/Karthik/eBooks/ "*".pdf'
    Error: /undefinedfilename in (find /home/Karthik/eBooks/ "*".pdf)

    What's the right syntax?

    Spiffworks

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru bigtomrodney's Avatar
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    6,133
    Right I'm not at a Linux terminal now, but if you can just cat the PS files together beforehand and the files don't have any special characters or spaces in them this could be quite easy. If you run the ls command on that directory, do they come out in the right order? Also they are .ps files to begin with?

    I hope this doesn't exceed the length for a bash command

    If so, try this :-
    Code:
    cd /home/Karthik/eBooks/
    cat $(ls *.ps) > master.ps
    ps2pdf master.ps
    This is all just worked out here, make sure to back up before trying etc. Also this really only applies to your situation if you plan on running this often I'd recommend getting some error checking built into there. Good luck

  6. #5
    Just Joined!
    Join Date
    Jul 2009
    Location
    India
    Posts
    4
    Sorry, that was a typo. The files are in pdf, I'm trying to convert it to ps so that I can use cat. I still can't figure out how to convert the lot to ps.

    Your script doesn't seem to be working. I tried it on 2 ps files, but I got only the first one in the output.

    Oh and yes, when I run ls, they do come out in the right order.
    pdf2ps is the current problem.

    Can I use ls's output as the filename for pdf2ps? What's the right syntax?

    Thanks,
    Spiffworks

  7. #6
    Just Joined!
    Join Date
    Jul 2009
    Location
    India
    Posts
    4
    I found pdftk, but I'm getting error messages, the pdfs seem to be corrupt. Looking at ways of ignoring this. Thanks for the help @bigtomrodney

    Spiffworks

Posting Permissions

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