Batch download a series of files and add prefix to themRecursive glob?How to download all html files from a...

Is ideal gas incompressible?

How to become an Editorial board member?

Computing elements of a 1000 x 60 matrix exhausts RAM

Are clauses with "который" restrictive or non-restrictive by default?

How do you earn the reader's trust?

csname in newenviroment

Shell builtin `printf` line limit?

Can a UK national work as a paid shop assistant in the USA?

Surface of the 3x3x3 cube as a graph

What is this and what is the purpose of it?

Is it OK to look at the list of played moves during the game to determine the status of the 50 move rule?

Why the work done is positive when bringing 2 opposite charges together?

What is the winged creature on the back of the Mordenkainen's Tome of Foes book?

Why do the i8080 I/O instructions take a byte-sized operand to determine the port?

Department head said that group project may be rejected. How to mitigate?

How could the B-29 bomber back up under its own power?

Is there an idiom that means that you are in a very strong negotiation position in a negotiation?

What all did Brienne write about Jaime?

Can diplomats be allowed on the flight deck of a commercial European airline?

Illustrating that universal optimality is stronger than sphere packing

mmap: effect of other processes writing to a file previously mapped read-only

Is the default 512 byte physical sector size appropriate for SSD disks under Linux?

How do I write real-world stories separate from my country of origin?

Is a world with one country feeding everyone possible?



Batch download a series of files and add prefix to them


Recursive glob?How to download all html files from a URL's directory with wget?Download one html page with all needed graphics and linked pdf/zip filesHow do I securely download files in shell scripting?List files in current directory, prefix numericallyWget batch download and save failed linksBatch rename files, create subfolders and move files by patternAdd prefix and suffix to an input and send it as a commandwget only parent pages using {..}batch rename files in Ubuntu: sequential numbering, based on order in directory. (Ubuntu 16.04)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















So I have a list of downloadable links with a specific order, but the filenames are jumbled up



example.com/ddk.zip
example.com/453.zip
example.com/hth.zip


So I want to automatically prefix them as I download them, based on the order of the list of links, so they'd look like this:



001_ddk.zip
002_453.zip
003_hth.zip


Is there any way to achieve this in Bash?










share|improve this question







New contributor



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




















  • What are you stuck on? wget downloads a file. Remember to prefix the link with http:// or https://. Once downloaded you can rename the file with mv.

    – Philip Couling
    19 mins ago




















0















So I have a list of downloadable links with a specific order, but the filenames are jumbled up



example.com/ddk.zip
example.com/453.zip
example.com/hth.zip


So I want to automatically prefix them as I download them, based on the order of the list of links, so they'd look like this:



001_ddk.zip
002_453.zip
003_hth.zip


Is there any way to achieve this in Bash?










share|improve this question







New contributor



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




















  • What are you stuck on? wget downloads a file. Remember to prefix the link with http:// or https://. Once downloaded you can rename the file with mv.

    – Philip Couling
    19 mins ago
















0












0








0








So I have a list of downloadable links with a specific order, but the filenames are jumbled up



example.com/ddk.zip
example.com/453.zip
example.com/hth.zip


So I want to automatically prefix them as I download them, based on the order of the list of links, so they'd look like this:



001_ddk.zip
002_453.zip
003_hth.zip


Is there any way to achieve this in Bash?










share|improve this question







New contributor



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











So I have a list of downloadable links with a specific order, but the filenames are jumbled up



example.com/ddk.zip
example.com/453.zip
example.com/hth.zip


So I want to automatically prefix them as I download them, based on the order of the list of links, so they'd look like this:



001_ddk.zip
002_453.zip
003_hth.zip


Is there any way to achieve this in Bash?







bash download batch-jobs






share|improve this question







New contributor



doko 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



doko 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






New contributor



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








asked 36 mins ago









dokodoko

1




1




New contributor



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




New contributor




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















  • What are you stuck on? wget downloads a file. Remember to prefix the link with http:// or https://. Once downloaded you can rename the file with mv.

    – Philip Couling
    19 mins ago





















  • What are you stuck on? wget downloads a file. Remember to prefix the link with http:// or https://. Once downloaded you can rename the file with mv.

    – Philip Couling
    19 mins ago



















What are you stuck on? wget downloads a file. Remember to prefix the link with http:// or https://. Once downloaded you can rename the file with mv.

– Philip Couling
19 mins ago







What are you stuck on? wget downloads a file. Remember to prefix the link with http:// or https://. Once downloaded you can rename the file with mv.

– Philip Couling
19 mins ago












1 Answer
1






active

oldest

votes


















0














Here is a piece of script



#!/bin/bash

PATH=/bin:/sbin:/usr/bin:/usr/sbin

prefix=1

while read link; do
filename="$(printf "%03d" $prefix)_${link#*/}"
echo "wget $link -O $filename"
prefix=$((prefix+1))
done < <(cat /tmp/list)


obviously remove the the echo on the wget command to execute it for real



result:



$ bash script.sh
wget example.com/ddk.zip -O 001_ddk.zip
wget example.com/453.zip -O 002_453.zip
wget example.com/hth.zip -O 003_hth.zip
wget example.com/ddhth.zip -O 004_ddhth.zip
wget example.com/hggth.zip -O 005_hggth.zip
wget example.com/jhkhth.zip -O 006_jhkhth.zip


And yep, you'll need to edit your link list and add http:// or https:// before






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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
    });


    }
    });






    doko 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%2funix.stackexchange.com%2fquestions%2f519887%2fbatch-download-a-series-of-files-and-add-prefix-to-them%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Here is a piece of script



    #!/bin/bash

    PATH=/bin:/sbin:/usr/bin:/usr/sbin

    prefix=1

    while read link; do
    filename="$(printf "%03d" $prefix)_${link#*/}"
    echo "wget $link -O $filename"
    prefix=$((prefix+1))
    done < <(cat /tmp/list)


    obviously remove the the echo on the wget command to execute it for real



    result:



    $ bash script.sh
    wget example.com/ddk.zip -O 001_ddk.zip
    wget example.com/453.zip -O 002_453.zip
    wget example.com/hth.zip -O 003_hth.zip
    wget example.com/ddhth.zip -O 004_ddhth.zip
    wget example.com/hggth.zip -O 005_hggth.zip
    wget example.com/jhkhth.zip -O 006_jhkhth.zip


    And yep, you'll need to edit your link list and add http:// or https:// before






    share|improve this answer




























      0














      Here is a piece of script



      #!/bin/bash

      PATH=/bin:/sbin:/usr/bin:/usr/sbin

      prefix=1

      while read link; do
      filename="$(printf "%03d" $prefix)_${link#*/}"
      echo "wget $link -O $filename"
      prefix=$((prefix+1))
      done < <(cat /tmp/list)


      obviously remove the the echo on the wget command to execute it for real



      result:



      $ bash script.sh
      wget example.com/ddk.zip -O 001_ddk.zip
      wget example.com/453.zip -O 002_453.zip
      wget example.com/hth.zip -O 003_hth.zip
      wget example.com/ddhth.zip -O 004_ddhth.zip
      wget example.com/hggth.zip -O 005_hggth.zip
      wget example.com/jhkhth.zip -O 006_jhkhth.zip


      And yep, you'll need to edit your link list and add http:// or https:// before






      share|improve this answer


























        0












        0








        0







        Here is a piece of script



        #!/bin/bash

        PATH=/bin:/sbin:/usr/bin:/usr/sbin

        prefix=1

        while read link; do
        filename="$(printf "%03d" $prefix)_${link#*/}"
        echo "wget $link -O $filename"
        prefix=$((prefix+1))
        done < <(cat /tmp/list)


        obviously remove the the echo on the wget command to execute it for real



        result:



        $ bash script.sh
        wget example.com/ddk.zip -O 001_ddk.zip
        wget example.com/453.zip -O 002_453.zip
        wget example.com/hth.zip -O 003_hth.zip
        wget example.com/ddhth.zip -O 004_ddhth.zip
        wget example.com/hggth.zip -O 005_hggth.zip
        wget example.com/jhkhth.zip -O 006_jhkhth.zip


        And yep, you'll need to edit your link list and add http:// or https:// before






        share|improve this answer













        Here is a piece of script



        #!/bin/bash

        PATH=/bin:/sbin:/usr/bin:/usr/sbin

        prefix=1

        while read link; do
        filename="$(printf "%03d" $prefix)_${link#*/}"
        echo "wget $link -O $filename"
        prefix=$((prefix+1))
        done < <(cat /tmp/list)


        obviously remove the the echo on the wget command to execute it for real



        result:



        $ bash script.sh
        wget example.com/ddk.zip -O 001_ddk.zip
        wget example.com/453.zip -O 002_453.zip
        wget example.com/hth.zip -O 003_hth.zip
        wget example.com/ddhth.zip -O 004_ddhth.zip
        wget example.com/hggth.zip -O 005_hggth.zip
        wget example.com/jhkhth.zip -O 006_jhkhth.zip


        And yep, you'll need to edit your link list and add http:// or https:// before







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 13 mins ago









        darxmurfdarxmurf

        50411




        50411






















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










            draft saved

            draft discarded


















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













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












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
















            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f519887%2fbatch-download-a-series-of-files-and-add-prefix-to-them%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

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...