(This is on NT based Windows like 2000, XP, Vista, 7)

On the command-line, the percentage characters are ignored:

wget "http://www.justitie.nl/images/Handleiding%20voor%20verwerkers%20persoonsgegevens_tcm34-3940.pdf"

So it correctly downloads this file (each %20 becomes a space):

"http://www.justitie.nl/images/Handleiding voor verwerkers persoonsgegevens_tcm34-3940.pdf"

But inside a batchfile, all the %20 are being interpreted as expanding parameter 2 (which is empty) resulting in this file to get downloaded (each %20 becomes 0):

"http://www.justitie.nl/images/Handleiding0voor0verwerkers0persoonsgegevens_tcm34-3940.pdf"

Is there a way to circumvent the percentage parameter expansion?

--jeroen

link|improve this question

67% accept rate
feedback

2 Answers

up vote 5 down vote accepted

Double the percent sign:

wget "http://www.justitie.nl/images/Handleiding%%20voor%%20verwerkers%%20persoonsgegevens_tcm34-3940.pdf"
link|improve this answer
+1 thanks- this worked. – Jeroen Wiert Pluimers Dec 25 '09 at 11:26
feedback

% is used for variables in Windows' cmd.exe (and its predecessor command.com).

The escape character in cmd.exe is ^:

> echo foo^%bar
foo%bar
link|improve this answer
this does not work from inside a batch file; but Snark's solution works. This is the batch-file I tested: wget "justitie.nl/images/…; wget "justitie.nl/images/Handleiding^%20voor^%20verwerkers^%20persoonsgege‌​vens_tcm34-3940.pdf" – Jeroen Wiert Pluimers Dec 25 '09 at 11:26
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.