[SOLVED] wget question, how to combine -i foo.txt and -O name.jpg
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
created a single file named lass.date.[0001-0100].jpg and that contained just the first file. I did see the output from curl grabbing 1-100.jpg , just didnt do as expected.
You should look up description of the -o option in the curl man page. It's
Code:
curl "URL/[1-100].jpg" -o "class.date.#1.jpg"
Thank you that is better, but instead of class.date.0001.jpg through class.date.1000.jpg or what ever the actual range is for the day, today its 0001-0011, i get outputs with ## instead of leading 0's.
Attempting to replace ###1 with 0001 results in a single output again.
for f in {1..1000}
do
zf="0000$f"
echo curl "url.$f.jpg" -o "class.date.${zf: -4}.jpg"
done
?
Running that with correct URL & 1...#, I get the echo output, but the command does not execute? would it not just be curl instead of echo curl inside the for loop?
edit to update:
So I removed the echo command and it works perfect. Thank you all for both the help and guidance.
Yep, the echo was so I could confirm I hadn't typed something wrong, but I didn't want to make requests / cleanup files.
Also I'll note that space after the colon is important - without it the substring expansion would instead set a default value if the parameter was unset or null - more details in the docs.
#!/bin/bash
# file to grab multiple web images/files and rename in local directory
# July 24, 2021
# f = total number of images to grab
# zf = listed number for output with leading zeros pre-padded in zf="0000$f"
# url = URL to grab files from
#url=https://foo/
#for f in {1..1000}
#do
# zf="0000${f}"
# curl "{url}${f}.jpg" -o "class.date.${zf: -4}.jpg"
#done
# copy/paste the URL in url= location
# adjust 1..1000 to match correct # of files to grab
# replace NN. with name of output file
url=
for f in {1..1000}
do
zf="0000${f}"
curl "${url}${f}.jpg" -o "NN.${zf: -4}.jpg"
done
Yes I intentionally have the raw code commented out. Helps me remember when I go back after time to read the code and figure out what its doing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.