3
I need to know where the error in the command is:
wget http://shadowera.com/cards/se{001..200}.jpg
I used the "shadowera" website for testing. I need to know how to save multiple images at once, and that way it’s not working.
3
I need to know where the error in the command is:
wget http://shadowera.com/cards/se{001..200}.jpg
I used the "shadowera" website for testing. I need to know how to save multiple images at once, and that way it’s not working.
6
Before using this loop, type cmd /v
in the console to enable parameter expansion:
set i=1000 && for /l %a in (1,1,200) do (
set /a "i=!i!+1" && wget http://shadowera.com/cards/se!i:~1,3!.jpg )
Line break is for easy reading only.
As we are using the CMD, and not a Shell, the expansion {001..200}
does not work. The solution found was a for
.
for /l %a in (1,1,200) do ( ...comandos... )
The initial problem is that the maximum one for
normal CMD would give us, would be a count from 1 to 200, and not from 001 to 200, which is the required output for the problem, given that the files are se001.jpg
to se200.jpg
, and not se1.jpg
onward.
So the simple solution would be to count from 1001 to 1200 and take advantage of the last three digits only. For this, the initial idea would be to use CMD substrings:
%variavel:~posicaoinicial,final%
Since nothing is simple, unfortunately the CMD substrings only work for "conventional" environment variables, and do not apply to the for, %a
in the case.
For this, we use an additional variable, i
, starting with 1000, and increasing it during the loop. To keep everything in one line, we use the &&
(and) to concatenate commands.
set i=1000 && ..for.. ( set /a "i=%i%+1 ..
But... this doesn’t work!
It does not work because the assignment of sets is done first, and it will execute the next command with the wrong values.
The solution: start a CMD with flag /V
, that activates the delayed expansion of the variable, which solves our problem. For this we use the format !variavel!
in place of %variável%
The result is the compound command from the beginning of the response.
It worked perfectly, buddy. Could you explain your code? Vlw
I went to the line of the solution very complete in CMD, because it can be used for a diversity of other cases :) (and I was really curious to find a solution too)
Excellent @Bacco. Mto well explained. I thank you on behalf of all who were interested in the question. Vlw...
Browser other questions tagged windows cmd wget
You are not signed in. Login or sign up in order to post.
That one
wget
in Windows is the same GNU Wget [only ported, or used via Cygwin]? If it is, these examples of use can solve. Trywget -r -l1 --no-parent -A se[0-2][0-9][0-9].gif http://shadowera.com/cards/
– mgibsonbr
It’s GNU. The command does not download anything, it just creates the folder with the site name, but empty.
– Marlon Paranhos
I’m using the cmd
– Marlon Paranhos
try using shell, as this type of expansion {001.. 200} does not work in cmd. In cmd you could use for, but ai would go from 1 to 200 and not from 001 to 200.
– Bacco
I managed to do it using Cygwin. It seems that the problem is really the CMD. Brawl
– Marlon Paranhos