0

I am transferring a program from my computer (a mac) to my work PC (running Windows 7) and trying to reproduce a command line script that found files and passed them one at a time to a python program. I have no admin privileges on my PC so editing my PATHTEXT variable is not an option.

I used this command in my UNIX shell:

find /wip -name '*.csv' | xargs -L 1 python hipaaGenPOC_v2.py

On my PC I have tried using FORFILES

FORFILES /p test /c "python hipaaGenPOC_v3.py @PATH"

But all this does is open a python terminal for every file in the test directory.

Please help.

R

Woody Pride
  • 13,539
  • 9
  • 48
  • 62
  • yes it is, I will update the question – Woody Pride May 22 '18 at 18:43
  • You could ditch `FORFILES` and write a python program that does that part. – tdelaney May 22 '18 at 18:54
  • I could, but for other reasons I need the program to run in its entirety for each file, and then terminate. i.e. I do not want to simply iterate over files using `os` etc. – Woody Pride May 22 '18 at 18:56
  • 2
    Turns out that `FORFILES` doesn't add the script itself to the argument list. `FORFILES /p test /c "python python.exe hipaaGenPOC_v3.py @PATH"` should work for you. There is another question about this, so I'll dup it. – tdelaney May 22 '18 at 19:34
  • ..but `for fn in glob.glob(os.path.join('test', '*')): subprocess.call(sys.executable, 'hipaaGenPOC_v3.py'. fn])` (assuming you import those modules) should work also. – tdelaney May 22 '18 at 19:37
  • Thank you, this does work except that the script had to be in the test directory, which is in fact just the directory for input and output files. Anyway to fix that? – Woody Pride May 22 '18 at 21:00

0 Answers0