Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Extract Text via Applescript

$
0
0
Hi all,

I am trying to setup an Applescript to convert a group of PDFs to plain text. I have the script below, which almost works, but I can't get it to save the text file with a variable as a filename.

The script below works fine if I use the 'tester' variable, which explicitly sets the filename, however if i use the 'newName' variable which uses the original filename the script fails with the following error:-
Adobe Acrobat Professional got an error: "this.saveAs(\"/C7s.txt\", \"com.adobe.acrobat.plain-text\");" doesn't understand the do script message.

Script is:
tell application "Finder"

set theFolder to choose folder with prompt "Select a folder of PDFs:"
set theFiles to every file of theFolder

repeat with a from 1 to length of theFiles
set theFile to file ((item a of theFiles) as string)
set fileExtension to the name extension of theFile
set the fileName to the name of theFile
set the newName to text 1 thru -((length of fileExtension) + 2) of the fileName & ".txt"
set tester to "myDoc.txt"
tell application "Adobe Acrobat Professional"
open theFile
tell document 1
--save the file out as a text file using JavaScript
do script "this.saveAs(\"/" & newName & "\", \"com.adobe.acrobat.plain-text\");"
end tell
close document 1
end tell
end repeat
end tell

Any help would be much appreciated.

James
P.S. I am running Mac OS X.4.10 and Acrobat 8

Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>