Escaping space for CLI

I’m trying to use url2pdf (Alternative solutions for converting html to pdf) for a folder that has a space. But I can’t get it to work.

This command works fine:

/Users/beatrixwillius/Downloads/url2pdf/url2pdf -n URL -b YES -g YES -j YES -o Portrait -p /Users/beatrixwillius/Downloads -u file:///Users/beatrixwillius/Downloads/test.html

I have the html file in the folder “mehr test” and want the resulting pdf in there. I’ve tried the following variations:

/Users/beatrixwillius/Downloads/url2pdf/url2pdf -n URL -b YES -g YES -j YES -o Portrait -p /Users/beatrixwillius/Downloads/mehr\ test -u file:///Users/beatrixwillius/Downloads/mehr\ test/test.html

beatrixwillius@MacBook-Air-von-Beatrix ~ % /Users/beatrixwillius/Downloads/url2pdf/url2pdf -n URL -b YES -g YES -j YES -o Portrait -p “/Users/beatrixwillius/Downloads/mehr test” -u “file:///Users/beatrixwillius/Downloads/mehr test/test.html”

beatrixwillius@MacBook-Air-von-Beatrix ~ % /Users/beatrixwillius/Downloads/url2pdf/url2pdf -n URL -b YES -g YES -j YES -o Portrait -p ‘/Users/beatrixwillius/Downloads/mehr test’ -u ‘file:///Users/beatrixwillius/Downloads/mehr test/test.html’

What am I doing wrong?

Have you tried %20 instead of escaping the space in one of those attempts?

See:

2 Likes

Thanks, that was the problem.

URL schemes should accept “+” as a shortcut for %20 , so

-u "file:///Users/beatrixwillius/Downloads/mehr+test/test.html"

Should work too.

1 Like