2

Disclaimer: I am a beginner in python but have Drupal programming experience.

I have this:

f = ['/path/1.jpg', '/path/2.jpg', '/path/3.jpg'] #less than 1500 files

and I need to do this

call(['c:/program files/ABBYY FineReader 10/finereader.exe'] + f)

BUT, there is an argument limit (http://stackoverflow.com/questions/2381241/what-is-the-subprocess-popen-max-length-of-the-args-parameter) of 32K characters, so I need to drop the /path first. How can I proceed, allowing the .exe to locate the files?

Thanks!

mellow-yellow
  • 1,670
  • 1
  • 18
  • 38

2 Answers2

1

You should add cwd='/path/' into the args of your subprocess.call. This will change working directory to '/path/' for the executable (but note it is not used for searching the executable, so still provide your absolute path for that).

Then, assuming they are all in that same path, you can use:

import os
f = [os.path.basename(x) for x in f]
wim
  • 338,267
  • 99
  • 616
  • 750
0

It seems you are on Windows. In this case you could try to specify a wildcard '*.jpg' that might be processed by finereader.exe itself:

check_call(r'c:\path\to\finereader.exe *.jpg', cwd=r'c:\jpg\dir')
jfs
  • 399,953
  • 195
  • 994
  • 1,670