Download files from file list wget
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
New contributor
add a comment |
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
New contributor
add a comment |
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
New contributor
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
command-line scripts
New contributor
New contributor
edited 1 hour ago
Ravexina
31.8k1482112
31.8k1482112
New contributor
asked 1 hour ago
no nameno name
61
61
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered 4 mins ago
RoVoRoVo
6,9781741
6,9781741
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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