1

I've read probably 20 stacks and have tried to mash together an answer and it just isn't coming together. I need to loop over a set of files in a directory, running a command on them as I go, and log the output. (Ideally a text compare on the output from the command would be nice, but I'm fine to read through the log.) PROBLEM: The following command doesn't output the result to the txt file. It outputs the "dumpbin /HEADERS...." into the txt. The command itself is not being run.

for %%f in ('dir /b "\\machine\c$\Program Files (x86)\software\bin64\*"') do (dumpbin /HEADERS %%f | find "machine")

Then I'm running look.bat >>foo.txt

The above is meant to pump out either 32bit word machine or 8664 machine (x64) depending on the file when run from VS Command prompt.

I've also tried the following with no difference.

for /f "usebackq delims=|" %%f in ('dir /b "\\machine\c$\Program Files (x86)\software\bin64\*"') do (dumpbin /HEADERS %%f | find "machine")
KHibma
  • 2,927
  • 4
  • 20
  • 25
  • possible duplicate of [How to do something to each file in a directory with a batch script](http://stackoverflow.com/questions/180741/how-to-do-something-to-each-file-in-a-directory-with-a-batch-script) – Ken White Sep 23 '14 at 18:50
  • and what's the problem? the script is not working? or you have distinct 64b and 32b machines? – npocmaka Sep 23 '14 at 18:59
  • I've added /f "usebackq delims=|" per the possible duplicate, no change. My problem is I cant get any output from the dumpbin command into my txt output. It outputs the command txt, it doesn't run the command. – KHibma Sep 23 '14 at 19:01
  • aa yes you need `/f "usebackq tokens=* delims="`.Try to map `\\qaloan010\c$\` as a drive letter.Not sure if dir command will access the path like that. – npocmaka Sep 23 '14 at 19:07
  • You need to map the unc path to a drive letter. – joojaa Sep 23 '14 at 19:46

1 Answers1

1

Finally found the right combination.

for /f %%f in ("\\qaloan010\c$\temp\bin64\*.*") do dumpbin /HEADERS %%f | find "machine">>output.TXT

8664 machine (x64)

8664 machine (x64)

.....

The space in "program files" might have been causing a problem, or it might have been the "dir \b path" qualifier. The access over UNC via c$ works fine if you have appropriate permissions.

KHibma
  • 2,927
  • 4
  • 20
  • 25
  • not space but the closing bracket...If you escape the bracket with "^" it should work.but it hit me when I saw your self-answer. – npocmaka Sep 23 '14 at 19:55