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

Anthony
  • 153
  • 1
  • 7

1 Answers1

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"
}
Anthony
  • 153
  • 1
  • 7