View Full Version : Command line: Using asterisk to select all files inside quotes for a directory name

06-22-2009, 04:57 PM
I'm running a command line utility on my ASP web site which takes an input of a list of file names along with other parameters. The following command works fine:

pdftk D:\testfolder\*.pdf other_parameter other_parameter

But then my folder path actually has a space in it so I need to do this:

pdftk "D:\test folder\*.pdf" other_parameter other_parameter

but this doesn't work because the quotes makes the asterisk a string character and does not use it as a special character anymore.

How do I work around this without renaming folders or anything along those lines where it requires me to change the input? Thanks

06-22-2009, 05:39 PM
Try surrounding only the space-separated directory names with quotes:

pdftk D:\"test folder"\*.pdf other_parameter other_parameter

06-22-2009, 06:27 PM
Tried it. Doesn't seem to work.

It splits it up where the quotation marks are inserted. Below is what happens:

D:\PDF Merge Toolkit>pdftk D:\"test folder"\*.pdf cat output "D:\testfolder\comb
Error: Failed to open PDF file:
Error: Failed to open PDF file:
folder\*.pdf cat output D:\testfolder\combined.pdf
Done. Input errors, so no output created.

Any other suggestions, thanks.

06-22-2009, 06:54 PM
It works straight from the command line, so it must be the program itself that's messing with it. That's what it looks like from this:


The program is using the windows directory separator as a real backslash - it's escaping the first double quote.

The workaround may be to use double backslashes in the path. That might force it to escape the directory separator and leave it in place. Like so:

pdftk D:\\"test folder"\\*.pdf other_parameter other_parameter

With the behavior above, though, I'm not sure how the program is handling that parameter internally.

06-22-2009, 07:43 PM
Thank you for the explanation. I learned something new today.

And yes the double slash fix does work. I'm very thankful. Hopefully, like you said this doesn't mean something is messed up with the way it handles blackslashes.