Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I cant for the life of me figure out what I'm missing. I have the following batch file:

As you can see, when I run this batch file from my desk against a mapped drive it runs just fine:

When I run the same exact batch file on the server itself, the place where the mapped drive is located on, it doesnt run and makes me think I have a syntax problem:

I just dont understand whats going on, and my eyes are having a hard time keeping track of what might be diff. The server where it isnt working is windows 2003, my desktop where the same batch file is working is Windows 7. Here is the batch file, nothing crazy:

FOR /D /r %%G in ("*") DO pdftk "%%G\*.pdf" cat output "%%G\Report.pdf"
share|improve this question
please don't add [belongs-on-X] tags. – quack quixote Jan 14 '10 at 23:18
@duhaas: the screenshots are informative, but since they're all text it'd be much more legible if you used the markup code formatting (indent 4 spaces) (or use the HTML <pre></pre> tags). – quack quixote Jan 14 '10 at 23:26
thanks for the suggestion, still getting used to these sites. can you example the: please don't add [belongs-on-X] tags – duhaas Jan 15 '10 at 14:01
@duhaas: the "please don't add [belongs-on-X] tags" was directed at others editing the tags on this question; it was not directed at you. (sorry for the confusion.) – quack quixote Jan 15 '10 at 23:32
FOR /D /r %%G in ("*") DO pdftk "%%G\*.pdf" cat output "%%G\Report.pdf"

Try this

FOR /D /r %%G in ("*") DO pdftk %%G\*.pdf cat output "%%G\Report.pdf"

The quotations around "%%G\*.pdf" I believe made the * look like a letter to the batch command and not a wildcard qualifier.

sorry if this is old but I just found it and used it.

share|improve this answer

The problem looks like you can do wildcard expansion in the set part of your command, the ("*"), but the command parameters "%%G\*.pdf" are not getting expanded. Why it's behaving inconsistently from one machine to the other, I'm not sure.

Since you only want to process pdf docs, move the wildcard * make you command like:

FOR /D /r %%G in ("*.pdf") DO pdftk "%%G" cat output "%%G\Report.pdf"
share|improve this answer
in the last paragraph he says the server's Win2k3, desktop is Win7. i expect the full explanation has to to do with Win2k3's command shell. – quack quixote Jan 15 '10 at 0:01
thanks for the suggestion dave, doesnt appear that helps as then it no longers cycles through the actual folders when i do that, it basically does nothing. – duhaas Jan 15 '10 at 14:00
@~quack. You may be right. duhas' original syntax & mine works on XP, vista & win7. Another culprit is the FOR command itself on Win2k3. Can't find a documented smoking gun, however, & I don't have a copy of that OS to play with. – DaveParillo Jan 16 '10 at 4:06
well, i'm assuming the FOR command is a shell-builtin command instead of a separate executable, but whichever, we're talking about the same thing. i'd help test but i don't have w2k3 either. :-/ – quack quixote Jan 16 '10 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .