How to send a zip file containing bunch of pdf's directly to a printer?












0















I receive regularly a bunch of pdf's as a single zip file. I would like to send these directly to a printer.



I found a nice script which allows using the right-click context menu to send the pdf's directly to a printer.



Print pdf file directly without opening it?



Now I would like to modify the script so that it would unzip the file and then send the pdf's to printer. How can I accomplish this?










share|improve this question



























    0















    I receive regularly a bunch of pdf's as a single zip file. I would like to send these directly to a printer.



    I found a nice script which allows using the right-click context menu to send the pdf's directly to a printer.



    Print pdf file directly without opening it?



    Now I would like to modify the script so that it would unzip the file and then send the pdf's to printer. How can I accomplish this?










    share|improve this question

























      0












      0








      0








      I receive regularly a bunch of pdf's as a single zip file. I would like to send these directly to a printer.



      I found a nice script which allows using the right-click context menu to send the pdf's directly to a printer.



      Print pdf file directly without opening it?



      Now I would like to modify the script so that it would unzip the file and then send the pdf's to printer. How can I accomplish this?










      share|improve this question














      I receive regularly a bunch of pdf's as a single zip file. I would like to send these directly to a printer.



      I found a nice script which allows using the right-click context menu to send the pdf's directly to a printer.



      Print pdf file directly without opening it?



      Now I would like to modify the script so that it would unzip the file and then send the pdf's to printer. How can I accomplish this?







      command-line printing pdf unzip






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 8 at 9:53









      Ossi ViljakainenOssi Viljakainen

      1051210




      1051210






















          3 Answers
          3






          active

          oldest

          votes


















          5














          If you want a simple "one liner", you can use the -p option of unzip




          -p extract files to pipe (stdout).

          Nothing but the file data is sent to stdout, and the files are always

          extracted in binary format, just as they are stored (no conversions).




          So it's a matter of piping the output to lpr:



          unzip -p archive_with_lots_of_pdfs.zip | lpr


          and you can easily adapt the script you linked to use this command.



          Note that the -c option is similar




          -c extract files to stdout/screen (``CRT'').




          But it prints the filename before the actual content. This will break your lpr command and probably will print garbage.






          share|improve this answer


























          • Great! I tried, with the following command, but it printed only the first pdf contained in the zipfile. $ unzip -p invoices_11379 (20).zip | lpr

            – Ossi Viljakainen
            Feb 14 at 14:38



















          1














          Try this:



          mkdir -p files
          unzip pdfs.zip -d files
          lpr files/*.pdf



          1. Command will create directory

          2. Unzip zip to files directory

          3. Print all pdf files


          Edit, nautilus script:



          #!/bin/bash
          mkdir -p /tmp/unzip_files
          unzip "$NAUTILUS_SCRIPT_CURRENT_URI" -d /tmp/unzip_files #unzip selected files to tmp directory
          lpr -r /tmp/unzip_files/*.pdf #print and remove file





          share|improve this answer


























          • How to make this into a script that I can save in nautilus scripts, so that I could envoke it throught the right-click menu in nautilus?

            – Ossi Viljakainen
            Feb 14 at 13:59






          • 1





            @OssiViljakainen I don't have nautilus installed but after googling some things about it, I edited answer with code for it. It should work, so try it.

            – Matej
            Feb 14 at 14:27











          • I tried your above solution: the individual lines do work. But the script doesn't. The issue with the script is that I think the variable "$NAUTILUS_SCRIPT_CURRENT_URI" doesn't give the URI correctly, and as a result the script doesn't do anything.

            – Ossi Viljakainen
            Feb 26 at 9:16











          • should echo command be used, along these lines: frenssen.be/…

            – Ossi Viljakainen
            Feb 26 at 9:28



















          0














          Now got it working.
          One must use "NAUTILUS_SCRIPT_SELECTED_URIS" as there are multiple files.



          #!/bin/bash 

          current_nautilus_path=$(echo "$NAUTILUS_SCRIPT_SELECTED_URIS" | sed -e 's/%/\x/g' -e 's_^file://__' | xargs -0 printf "%b") #get the URI variable from nautilus
          mkdir -p /tmp/unzip_files "$current_nautilus_path" -d /tmp/unzip_files #unzip selected files to tmp directory
          lpr -r /tmp/unzip_files/*.pdf #print and remove file





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1116625%2fhow-to-send-a-zip-file-containing-bunch-of-pdfs-directly-to-a-printer%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            If you want a simple "one liner", you can use the -p option of unzip




            -p extract files to pipe (stdout).

            Nothing but the file data is sent to stdout, and the files are always

            extracted in binary format, just as they are stored (no conversions).




            So it's a matter of piping the output to lpr:



            unzip -p archive_with_lots_of_pdfs.zip | lpr


            and you can easily adapt the script you linked to use this command.



            Note that the -c option is similar




            -c extract files to stdout/screen (``CRT'').




            But it prints the filename before the actual content. This will break your lpr command and probably will print garbage.






            share|improve this answer


























            • Great! I tried, with the following command, but it printed only the first pdf contained in the zipfile. $ unzip -p invoices_11379 (20).zip | lpr

              – Ossi Viljakainen
              Feb 14 at 14:38
















            5














            If you want a simple "one liner", you can use the -p option of unzip




            -p extract files to pipe (stdout).

            Nothing but the file data is sent to stdout, and the files are always

            extracted in binary format, just as they are stored (no conversions).




            So it's a matter of piping the output to lpr:



            unzip -p archive_with_lots_of_pdfs.zip | lpr


            and you can easily adapt the script you linked to use this command.



            Note that the -c option is similar




            -c extract files to stdout/screen (``CRT'').




            But it prints the filename before the actual content. This will break your lpr command and probably will print garbage.






            share|improve this answer


























            • Great! I tried, with the following command, but it printed only the first pdf contained in the zipfile. $ unzip -p invoices_11379 (20).zip | lpr

              – Ossi Viljakainen
              Feb 14 at 14:38














            5












            5








            5







            If you want a simple "one liner", you can use the -p option of unzip




            -p extract files to pipe (stdout).

            Nothing but the file data is sent to stdout, and the files are always

            extracted in binary format, just as they are stored (no conversions).




            So it's a matter of piping the output to lpr:



            unzip -p archive_with_lots_of_pdfs.zip | lpr


            and you can easily adapt the script you linked to use this command.



            Note that the -c option is similar




            -c extract files to stdout/screen (``CRT'').




            But it prints the filename before the actual content. This will break your lpr command and probably will print garbage.






            share|improve this answer















            If you want a simple "one liner", you can use the -p option of unzip




            -p extract files to pipe (stdout).

            Nothing but the file data is sent to stdout, and the files are always

            extracted in binary format, just as they are stored (no conversions).




            So it's a matter of piping the output to lpr:



            unzip -p archive_with_lots_of_pdfs.zip | lpr


            and you can easily adapt the script you linked to use this command.



            Note that the -c option is similar




            -c extract files to stdout/screen (``CRT'').




            But it prints the filename before the actual content. This will break your lpr command and probably will print garbage.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 8 at 17:26

























            answered Feb 8 at 10:06









            Mr ShunzMr Shunz

            2,49121922




            2,49121922













            • Great! I tried, with the following command, but it printed only the first pdf contained in the zipfile. $ unzip -p invoices_11379 (20).zip | lpr

              – Ossi Viljakainen
              Feb 14 at 14:38



















            • Great! I tried, with the following command, but it printed only the first pdf contained in the zipfile. $ unzip -p invoices_11379 (20).zip | lpr

              – Ossi Viljakainen
              Feb 14 at 14:38

















            Great! I tried, with the following command, but it printed only the first pdf contained in the zipfile. $ unzip -p invoices_11379 (20).zip | lpr

            – Ossi Viljakainen
            Feb 14 at 14:38





            Great! I tried, with the following command, but it printed only the first pdf contained in the zipfile. $ unzip -p invoices_11379 (20).zip | lpr

            – Ossi Viljakainen
            Feb 14 at 14:38













            1














            Try this:



            mkdir -p files
            unzip pdfs.zip -d files
            lpr files/*.pdf



            1. Command will create directory

            2. Unzip zip to files directory

            3. Print all pdf files


            Edit, nautilus script:



            #!/bin/bash
            mkdir -p /tmp/unzip_files
            unzip "$NAUTILUS_SCRIPT_CURRENT_URI" -d /tmp/unzip_files #unzip selected files to tmp directory
            lpr -r /tmp/unzip_files/*.pdf #print and remove file





            share|improve this answer


























            • How to make this into a script that I can save in nautilus scripts, so that I could envoke it throught the right-click menu in nautilus?

              – Ossi Viljakainen
              Feb 14 at 13:59






            • 1





              @OssiViljakainen I don't have nautilus installed but after googling some things about it, I edited answer with code for it. It should work, so try it.

              – Matej
              Feb 14 at 14:27











            • I tried your above solution: the individual lines do work. But the script doesn't. The issue with the script is that I think the variable "$NAUTILUS_SCRIPT_CURRENT_URI" doesn't give the URI correctly, and as a result the script doesn't do anything.

              – Ossi Viljakainen
              Feb 26 at 9:16











            • should echo command be used, along these lines: frenssen.be/…

              – Ossi Viljakainen
              Feb 26 at 9:28
















            1














            Try this:



            mkdir -p files
            unzip pdfs.zip -d files
            lpr files/*.pdf



            1. Command will create directory

            2. Unzip zip to files directory

            3. Print all pdf files


            Edit, nautilus script:



            #!/bin/bash
            mkdir -p /tmp/unzip_files
            unzip "$NAUTILUS_SCRIPT_CURRENT_URI" -d /tmp/unzip_files #unzip selected files to tmp directory
            lpr -r /tmp/unzip_files/*.pdf #print and remove file





            share|improve this answer


























            • How to make this into a script that I can save in nautilus scripts, so that I could envoke it throught the right-click menu in nautilus?

              – Ossi Viljakainen
              Feb 14 at 13:59






            • 1





              @OssiViljakainen I don't have nautilus installed but after googling some things about it, I edited answer with code for it. It should work, so try it.

              – Matej
              Feb 14 at 14:27











            • I tried your above solution: the individual lines do work. But the script doesn't. The issue with the script is that I think the variable "$NAUTILUS_SCRIPT_CURRENT_URI" doesn't give the URI correctly, and as a result the script doesn't do anything.

              – Ossi Viljakainen
              Feb 26 at 9:16











            • should echo command be used, along these lines: frenssen.be/…

              – Ossi Viljakainen
              Feb 26 at 9:28














            1












            1








            1







            Try this:



            mkdir -p files
            unzip pdfs.zip -d files
            lpr files/*.pdf



            1. Command will create directory

            2. Unzip zip to files directory

            3. Print all pdf files


            Edit, nautilus script:



            #!/bin/bash
            mkdir -p /tmp/unzip_files
            unzip "$NAUTILUS_SCRIPT_CURRENT_URI" -d /tmp/unzip_files #unzip selected files to tmp directory
            lpr -r /tmp/unzip_files/*.pdf #print and remove file





            share|improve this answer















            Try this:



            mkdir -p files
            unzip pdfs.zip -d files
            lpr files/*.pdf



            1. Command will create directory

            2. Unzip zip to files directory

            3. Print all pdf files


            Edit, nautilus script:



            #!/bin/bash
            mkdir -p /tmp/unzip_files
            unzip "$NAUTILUS_SCRIPT_CURRENT_URI" -d /tmp/unzip_files #unzip selected files to tmp directory
            lpr -r /tmp/unzip_files/*.pdf #print and remove file






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 14 at 14:26

























            answered Feb 8 at 9:57









            MatejMatej

            11113




            11113













            • How to make this into a script that I can save in nautilus scripts, so that I could envoke it throught the right-click menu in nautilus?

              – Ossi Viljakainen
              Feb 14 at 13:59






            • 1





              @OssiViljakainen I don't have nautilus installed but after googling some things about it, I edited answer with code for it. It should work, so try it.

              – Matej
              Feb 14 at 14:27











            • I tried your above solution: the individual lines do work. But the script doesn't. The issue with the script is that I think the variable "$NAUTILUS_SCRIPT_CURRENT_URI" doesn't give the URI correctly, and as a result the script doesn't do anything.

              – Ossi Viljakainen
              Feb 26 at 9:16











            • should echo command be used, along these lines: frenssen.be/…

              – Ossi Viljakainen
              Feb 26 at 9:28



















            • How to make this into a script that I can save in nautilus scripts, so that I could envoke it throught the right-click menu in nautilus?

              – Ossi Viljakainen
              Feb 14 at 13:59






            • 1





              @OssiViljakainen I don't have nautilus installed but after googling some things about it, I edited answer with code for it. It should work, so try it.

              – Matej
              Feb 14 at 14:27











            • I tried your above solution: the individual lines do work. But the script doesn't. The issue with the script is that I think the variable "$NAUTILUS_SCRIPT_CURRENT_URI" doesn't give the URI correctly, and as a result the script doesn't do anything.

              – Ossi Viljakainen
              Feb 26 at 9:16











            • should echo command be used, along these lines: frenssen.be/…

              – Ossi Viljakainen
              Feb 26 at 9:28

















            How to make this into a script that I can save in nautilus scripts, so that I could envoke it throught the right-click menu in nautilus?

            – Ossi Viljakainen
            Feb 14 at 13:59





            How to make this into a script that I can save in nautilus scripts, so that I could envoke it throught the right-click menu in nautilus?

            – Ossi Viljakainen
            Feb 14 at 13:59




            1




            1





            @OssiViljakainen I don't have nautilus installed but after googling some things about it, I edited answer with code for it. It should work, so try it.

            – Matej
            Feb 14 at 14:27





            @OssiViljakainen I don't have nautilus installed but after googling some things about it, I edited answer with code for it. It should work, so try it.

            – Matej
            Feb 14 at 14:27













            I tried your above solution: the individual lines do work. But the script doesn't. The issue with the script is that I think the variable "$NAUTILUS_SCRIPT_CURRENT_URI" doesn't give the URI correctly, and as a result the script doesn't do anything.

            – Ossi Viljakainen
            Feb 26 at 9:16





            I tried your above solution: the individual lines do work. But the script doesn't. The issue with the script is that I think the variable "$NAUTILUS_SCRIPT_CURRENT_URI" doesn't give the URI correctly, and as a result the script doesn't do anything.

            – Ossi Viljakainen
            Feb 26 at 9:16













            should echo command be used, along these lines: frenssen.be/…

            – Ossi Viljakainen
            Feb 26 at 9:28





            should echo command be used, along these lines: frenssen.be/…

            – Ossi Viljakainen
            Feb 26 at 9:28











            0














            Now got it working.
            One must use "NAUTILUS_SCRIPT_SELECTED_URIS" as there are multiple files.



            #!/bin/bash 

            current_nautilus_path=$(echo "$NAUTILUS_SCRIPT_SELECTED_URIS" | sed -e 's/%/\x/g' -e 's_^file://__' | xargs -0 printf "%b") #get the URI variable from nautilus
            mkdir -p /tmp/unzip_files "$current_nautilus_path" -d /tmp/unzip_files #unzip selected files to tmp directory
            lpr -r /tmp/unzip_files/*.pdf #print and remove file





            share|improve this answer




























              0














              Now got it working.
              One must use "NAUTILUS_SCRIPT_SELECTED_URIS" as there are multiple files.



              #!/bin/bash 

              current_nautilus_path=$(echo "$NAUTILUS_SCRIPT_SELECTED_URIS" | sed -e 's/%/\x/g' -e 's_^file://__' | xargs -0 printf "%b") #get the URI variable from nautilus
              mkdir -p /tmp/unzip_files "$current_nautilus_path" -d /tmp/unzip_files #unzip selected files to tmp directory
              lpr -r /tmp/unzip_files/*.pdf #print and remove file





              share|improve this answer


























                0












                0








                0







                Now got it working.
                One must use "NAUTILUS_SCRIPT_SELECTED_URIS" as there are multiple files.



                #!/bin/bash 

                current_nautilus_path=$(echo "$NAUTILUS_SCRIPT_SELECTED_URIS" | sed -e 's/%/\x/g' -e 's_^file://__' | xargs -0 printf "%b") #get the URI variable from nautilus
                mkdir -p /tmp/unzip_files "$current_nautilus_path" -d /tmp/unzip_files #unzip selected files to tmp directory
                lpr -r /tmp/unzip_files/*.pdf #print and remove file





                share|improve this answer













                Now got it working.
                One must use "NAUTILUS_SCRIPT_SELECTED_URIS" as there are multiple files.



                #!/bin/bash 

                current_nautilus_path=$(echo "$NAUTILUS_SCRIPT_SELECTED_URIS" | sed -e 's/%/\x/g' -e 's_^file://__' | xargs -0 printf "%b") #get the URI variable from nautilus
                mkdir -p /tmp/unzip_files "$current_nautilus_path" -d /tmp/unzip_files #unzip selected files to tmp directory
                lpr -r /tmp/unzip_files/*.pdf #print and remove file






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 27 at 18:55









                Ossi ViljakainenOssi Viljakainen

                1051210




                1051210






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1116625%2fhow-to-send-a-zip-file-containing-bunch-of-pdfs-directly-to-a-printer%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to make a Squid Proxy server?

                    Is this a new Fibonacci Identity?

                    19世紀