-3

I am trying to execute a windows script against bunch of files in a directory. This script checks the format of the files it it is not good, I need to write to the log.txt file so that I can go back and fix each file.

I tried this:

for /f "Tokens=*" %f in ('dir /l/b/a-d') do (testscript -l "%f") >>logs.txt

I need to now the file names as well.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
user1471980
  • 10,127
  • 48
  • 136
  • 235

1 Answers1

1

The last line of forfiles /? shows something similar to this:

FORFILES /M * /C "cmd /c if @isdir==FALSE testscript.exe @file"
Gerhard
  • 22,678
  • 7
  • 27
  • 43
Dominique
  • 16,450
  • 15
  • 56
  • 112
  • this kinda works, can you only print out the files that have errors. Errors would have this text in it "invalid" – user1471980 Oct 22 '20 at 20:16
  • @user1471980: you can add a `| findstr "invalid"` at the end, this filters the output on that particular word. – Dominique Oct 23 '20 at 14:40