Download files from file list wget












1















I have a file where are written downloading links



Google.com/image2
Google.com/image3
Google.com/image4
Google.com/image5
Google.com/image6


I want to download all of them with scripts. If the name starts 's' move this file s directory, if it's b, then move it to b directory.










share|improve this question









New contributor




no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    I have a file where are written downloading links



    Google.com/image2
    Google.com/image3
    Google.com/image4
    Google.com/image5
    Google.com/image6


    I want to download all of them with scripts. If the name starts 's' move this file s directory, if it's b, then move it to b directory.










    share|improve this question









    New contributor




    no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1


      1






      I have a file where are written downloading links



      Google.com/image2
      Google.com/image3
      Google.com/image4
      Google.com/image5
      Google.com/image6


      I want to download all of them with scripts. If the name starts 's' move this file s directory, if it's b, then move it to b directory.










      share|improve this question









      New contributor




      no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have a file where are written downloading links



      Google.com/image2
      Google.com/image3
      Google.com/image4
      Google.com/image5
      Google.com/image6


      I want to download all of them with scripts. If the name starts 's' move this file s directory, if it's b, then move it to b directory.







      command-line scripts






      share|improve this question









      New contributor




      no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 1 hour ago









      Ravexina

      31.8k1482112




      31.8k1482112






      New contributor




      no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 hour ago









      no nameno name

      61




      61




      New contributor




      no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      no name is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          4














          Download all files, then move them using shell globs:



          #!/bin/bash
          wget -i /path/to/download_list
          mv s* ./s/
          mv b* ./b/




          • -i: Read URLs from a local or external file.


          You might get a warning:



          mv: cannot move 's' to a subdirectory of itself.


          That's fine, you can ignore it, or use find instead:



          #!/bin/bash
          wget -i /path/to/download_list
          find -maxdepth 1 -iname "s*" -type f -exec mv "{}" ./s ;
          find -maxdepth 1 -iname "b*" -type f -exec mv "{}" ./b ;




          And with a for loop you can run in on all alphabets, script name is script.sh:



          #!/bin/bash
          wget -i /path/to/download_list
          mkdir -p {a..z}
          for l in {a..z};
          do
          find -maxdepth 1 -type f -iname "${l}*" -not -iname script.sh -exec mv "{}" "./${l}" ;
          done





          share|improve this answer


























          • i want with scripts

            – no name
            1 hour ago











          • What you are seeing in my answer is a simple script, save it in a file, make it executable, then run it. You have to change it so it suits your needs.

            – Ravexina
            1 hour ago













          • if file name starting c or x or k ? write all variants?

            – no name
            57 mins ago











          • You didn't mention that in your question, then you have to use a loop, I'll update the answer.

            – Ravexina
            56 mins ago











          • uea ,i want to use loop

            – no name
            50 mins ago



















          0














          An addition to @Ravexina's nice answer.



          Solution without a loop:



          wget -i /path/to/download_list
          mkdir -p {a..z}
          # mv the files with rename tool
          rename 's/^((.).+)$/$2/$1/' *
          # clean up empty directories
          find . -maxdepth 1 -name '[a-z]' -type d -empty -delete




          share























            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
            });


            }
            });






            no name is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1109848%2fdownload-files-from-file-list-wget%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            Download all files, then move them using shell globs:



            #!/bin/bash
            wget -i /path/to/download_list
            mv s* ./s/
            mv b* ./b/




            • -i: Read URLs from a local or external file.


            You might get a warning:



            mv: cannot move 's' to a subdirectory of itself.


            That's fine, you can ignore it, or use find instead:



            #!/bin/bash
            wget -i /path/to/download_list
            find -maxdepth 1 -iname "s*" -type f -exec mv "{}" ./s ;
            find -maxdepth 1 -iname "b*" -type f -exec mv "{}" ./b ;




            And with a for loop you can run in on all alphabets, script name is script.sh:



            #!/bin/bash
            wget -i /path/to/download_list
            mkdir -p {a..z}
            for l in {a..z};
            do
            find -maxdepth 1 -type f -iname "${l}*" -not -iname script.sh -exec mv "{}" "./${l}" ;
            done





            share|improve this answer


























            • i want with scripts

              – no name
              1 hour ago











            • What you are seeing in my answer is a simple script, save it in a file, make it executable, then run it. You have to change it so it suits your needs.

              – Ravexina
              1 hour ago













            • if file name starting c or x or k ? write all variants?

              – no name
              57 mins ago











            • You didn't mention that in your question, then you have to use a loop, I'll update the answer.

              – Ravexina
              56 mins ago











            • uea ,i want to use loop

              – no name
              50 mins ago
















            4














            Download all files, then move them using shell globs:



            #!/bin/bash
            wget -i /path/to/download_list
            mv s* ./s/
            mv b* ./b/




            • -i: Read URLs from a local or external file.


            You might get a warning:



            mv: cannot move 's' to a subdirectory of itself.


            That's fine, you can ignore it, or use find instead:



            #!/bin/bash
            wget -i /path/to/download_list
            find -maxdepth 1 -iname "s*" -type f -exec mv "{}" ./s ;
            find -maxdepth 1 -iname "b*" -type f -exec mv "{}" ./b ;




            And with a for loop you can run in on all alphabets, script name is script.sh:



            #!/bin/bash
            wget -i /path/to/download_list
            mkdir -p {a..z}
            for l in {a..z};
            do
            find -maxdepth 1 -type f -iname "${l}*" -not -iname script.sh -exec mv "{}" "./${l}" ;
            done





            share|improve this answer


























            • i want with scripts

              – no name
              1 hour ago











            • What you are seeing in my answer is a simple script, save it in a file, make it executable, then run it. You have to change it so it suits your needs.

              – Ravexina
              1 hour ago













            • if file name starting c or x or k ? write all variants?

              – no name
              57 mins ago











            • You didn't mention that in your question, then you have to use a loop, I'll update the answer.

              – Ravexina
              56 mins ago











            • uea ,i want to use loop

              – no name
              50 mins ago














            4












            4








            4







            Download all files, then move them using shell globs:



            #!/bin/bash
            wget -i /path/to/download_list
            mv s* ./s/
            mv b* ./b/




            • -i: Read URLs from a local or external file.


            You might get a warning:



            mv: cannot move 's' to a subdirectory of itself.


            That's fine, you can ignore it, or use find instead:



            #!/bin/bash
            wget -i /path/to/download_list
            find -maxdepth 1 -iname "s*" -type f -exec mv "{}" ./s ;
            find -maxdepth 1 -iname "b*" -type f -exec mv "{}" ./b ;




            And with a for loop you can run in on all alphabets, script name is script.sh:



            #!/bin/bash
            wget -i /path/to/download_list
            mkdir -p {a..z}
            for l in {a..z};
            do
            find -maxdepth 1 -type f -iname "${l}*" -not -iname script.sh -exec mv "{}" "./${l}" ;
            done





            share|improve this answer















            Download all files, then move them using shell globs:



            #!/bin/bash
            wget -i /path/to/download_list
            mv s* ./s/
            mv b* ./b/




            • -i: Read URLs from a local or external file.


            You might get a warning:



            mv: cannot move 's' to a subdirectory of itself.


            That's fine, you can ignore it, or use find instead:



            #!/bin/bash
            wget -i /path/to/download_list
            find -maxdepth 1 -iname "s*" -type f -exec mv "{}" ./s ;
            find -maxdepth 1 -iname "b*" -type f -exec mv "{}" ./b ;




            And with a for loop you can run in on all alphabets, script name is script.sh:



            #!/bin/bash
            wget -i /path/to/download_list
            mkdir -p {a..z}
            for l in {a..z};
            do
            find -maxdepth 1 -type f -iname "${l}*" -not -iname script.sh -exec mv "{}" "./${l}" ;
            done






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 28 mins ago

























            answered 1 hour ago









            RavexinaRavexina

            31.8k1482112




            31.8k1482112













            • i want with scripts

              – no name
              1 hour ago











            • What you are seeing in my answer is a simple script, save it in a file, make it executable, then run it. You have to change it so it suits your needs.

              – Ravexina
              1 hour ago













            • if file name starting c or x or k ? write all variants?

              – no name
              57 mins ago











            • You didn't mention that in your question, then you have to use a loop, I'll update the answer.

              – Ravexina
              56 mins ago











            • uea ,i want to use loop

              – no name
              50 mins ago



















            • i want with scripts

              – no name
              1 hour ago











            • What you are seeing in my answer is a simple script, save it in a file, make it executable, then run it. You have to change it so it suits your needs.

              – Ravexina
              1 hour ago













            • if file name starting c or x or k ? write all variants?

              – no name
              57 mins ago











            • You didn't mention that in your question, then you have to use a loop, I'll update the answer.

              – Ravexina
              56 mins ago











            • uea ,i want to use loop

              – no name
              50 mins ago

















            i want with scripts

            – no name
            1 hour ago





            i want with scripts

            – no name
            1 hour ago













            What you are seeing in my answer is a simple script, save it in a file, make it executable, then run it. You have to change it so it suits your needs.

            – Ravexina
            1 hour ago







            What you are seeing in my answer is a simple script, save it in a file, make it executable, then run it. You have to change it so it suits your needs.

            – Ravexina
            1 hour ago















            if file name starting c or x or k ? write all variants?

            – no name
            57 mins ago





            if file name starting c or x or k ? write all variants?

            – no name
            57 mins ago













            You didn't mention that in your question, then you have to use a loop, I'll update the answer.

            – Ravexina
            56 mins ago





            You didn't mention that in your question, then you have to use a loop, I'll update the answer.

            – Ravexina
            56 mins ago













            uea ,i want to use loop

            – no name
            50 mins ago





            uea ,i want to use loop

            – no name
            50 mins ago













            0














            An addition to @Ravexina's nice answer.



            Solution without a loop:



            wget -i /path/to/download_list
            mkdir -p {a..z}
            # mv the files with rename tool
            rename 's/^((.).+)$/$2/$1/' *
            # clean up empty directories
            find . -maxdepth 1 -name '[a-z]' -type d -empty -delete




            share




























              0














              An addition to @Ravexina's nice answer.



              Solution without a loop:



              wget -i /path/to/download_list
              mkdir -p {a..z}
              # mv the files with rename tool
              rename 's/^((.).+)$/$2/$1/' *
              # clean up empty directories
              find . -maxdepth 1 -name '[a-z]' -type d -empty -delete




              share


























                0












                0








                0







                An addition to @Ravexina's nice answer.



                Solution without a loop:



                wget -i /path/to/download_list
                mkdir -p {a..z}
                # mv the files with rename tool
                rename 's/^((.).+)$/$2/$1/' *
                # clean up empty directories
                find . -maxdepth 1 -name '[a-z]' -type d -empty -delete




                share













                An addition to @Ravexina's nice answer.



                Solution without a loop:



                wget -i /path/to/download_list
                mkdir -p {a..z}
                # mv the files with rename tool
                rename 's/^((.).+)$/$2/$1/' *
                # clean up empty directories
                find . -maxdepth 1 -name '[a-z]' -type d -empty -delete





                share











                share


                share










                answered 4 mins ago









                RoVoRoVo

                6,9781741




                6,9781741






















                    no name is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    no name is a new contributor. Be nice, and check out our Code of Conduct.













                    no name is a new contributor. Be nice, and check out our Code of Conduct.












                    no name is a new contributor. Be nice, and check out our Code of Conduct.
















                    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%2f1109848%2fdownload-files-from-file-list-wget%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

                    Statuo de Libereco

                    Tanganjiko

                    Liste der Baudenkmäler in Enneberg