tags:

views:

886

answers:

2

I have a folder full of files i need to post to a webservice using cURL but i'm not sure on the whole variables and iterations in batch files thing.

I know the syntax for curl should be

c:\curl\bin\curl -X POST -F File=@[filename] -F "title=[title]" -F "notes=[notes]" "http://xxx/AddScannedImage?debtref=[filename]"

but the % symbols from the variables seem to get gobbled up in the URL encoding

Any ideas?

TIA

+3  A: 

You should try with the -g aka --globoff cURL option.

The default behavior is to :

You can specify multiple URLs or parts of URLs by writing part sets within braces as in:

http://site.{one,two,three}.com

or you can get sequences of alphanumeric series by using [] as in:

ftp://ftp.numericals.com/file[1-100].txt
ftp://ftp.numericals.com/file[001-100].txt    (with leading zeros)
ftp://ftp.letters.com/file[a-z].txt

No nesting of the sequences is supported at the moment, but you can use several ones next to each other:

http://any.org/archive[1996-1999]/vol[1-4]/part{a,b,c}.html

You can specify any amount of URLs on the command line. They will be fetched in a sequential manner in the specified order.

Since curl 7.15.1 you can also specify step counter for the ranges, so that you can get every Nth number or letter:

http://www.numericals.com/file[1-100:10].txt
http://www.letters.com/file[a-z:2].txt

You can even do :

    curl -T "img[1-1000].png" ftp://ftp.picturemania.com/upload/

But in your case, you really don't want that, so you should use the -g flag to tell it not to do globbing at all.

mat
A: 

The percent symbol (%) is a special character in Windows/DOS batch files. On the command line, you can use a single %. In a batch file, use two.

For example, if your URL contains a space which is encoded as %20, then you need %%20.

Al