In the below code, I am trying to take the path name (inclusive of file name) and converting them to another path name with text file.
Now I would like to pass both variable as argument for another py which will take it as argument
import os
thisdir=[os.path.join(r,file) for r,d,f in
os.walk("C:\\Users\\vnitin\\OneDrive - NetApp Inc\\IDP\\Files\\") for file
in f]
for i in range(len(thisdir)):
text_path = thisdir[i].replace('pdf', 'txt')
print(text_path)
os.system('py pdf2txt.py -o text_path thisdir[i]')
But individual command for pdf2txt.py works very well.
py .\pdf2txt.py -o 'C:\Users\vnitin\OneDrive - NetApp Inc\IDP\Files\11.txt'
'C:\Users\vnitin\OneDrive - NetApp Inc\IDP\Files\11.pdf'
since thisdir[i]
is not converted to its value during execution, so the error No such file or directory
Replace os.system('py pdf2txt.py -o text_path thisdir[i]')
with
os.system("python ./pdf2txt.py -o {0} {1}".format(text_path,thisdir[i]))