Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

(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

share|improve this question

2 Answers 2

up vote 8 down vote accepted

Double the percent sign:

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

% 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
share|improve this answer
2  
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
    
I did know @Snark's solution, but I wouldn't have guessed that this wouldn't also work. Surprising. –  user1167442 Nov 5 at 20:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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