1

Question: I am running the following script in Windows 10 via the PowerShell ISE

cd C:\Users\xyz\Desktop\pdfs
$FILES= ls *.pdf
foreach ($f in $FILES) {
  "C:\Program Files\xpdf-tools-win-4.01.01\bin32\pdftotext.exe" -enc UTF-8 "$f"
}

I am receiving the following errors

  • unexpected token 'enc' in expression or statement
  • unexpected token 'UTF-8' in expression or statement

How do I correct those error ?


I suspect, although I am by no means certain, the error is due to incorrect " or ' marks. I have attempted the following change

cd C:\Users\xyz\Desktop\pdfs
$FILES= ls *.pdf
foreach ($f in $FILES) {
  "C:\Program Files\xpdf-tools-win-4.01.01\bin32\pdftotext.exe -enc UTF-8 $f"
}

; which surprisingly executes but fails to generate any text files and I am expecting those files to be found in the folder ...\pdfs.

Reference

1 Answer 1

1

Solution: I was missing an ampersand, &. A deeper search on Stack Overflow turned up this question; which provided me with the correction. Very fast, and much faster than anything native in Adobe Acrobat DC !

cd C:\Users\xyz\Desktop\pdfs
$FILES= ls *.pdf
foreach ($f in $FILES) {
  & "C:\Program Files\xpdf-tools-win-4.01.01\bin32\pdftotext.exe" -enc UTF-8 "$f"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.