lisehu Posted May 11, 2011 Share Posted May 11, 2011 Application: Adobe Reader 10.0.1 I need to save multiple PDF files to text files. All the PDF files are reside in c:\data folder. Qn: 1) The script below is saving only one PDF file to text file. How do I save mulitple PDF file using While loop? this is my script: ; ; Runs Adobe Reader version 10.0.1 ; ;Runs PDF Application ShellExecute ("AcroRd32.exe") ;WinExists("Adobe Reader") ; Wait for Adobe Reader to become active WinWaitActive("Adobe Reader","","") Sleep(1000) ; Open File Send("^o") ;File Open using Control o Send("!n") ;Set cursor on File name path Sleep(500) ;Wait for 0.5 sec Send("C:\Data\outfile1") ;Enter outfile1.pdf full directory path Sleep(1000) Send("!o") ;Open outfile1.pdf ; Wait for Adobe Reader to become active WinWaitActive("outfile1.pdf - Adobe Reader","","") Send("!f") ;File Open Send("a") ;Save As Send("x") ;Text ; Wait for Save As Window to become active WinWaitActive("Save As","","") Send("!s") ;Save ; Wait for Adobe Reader to become active WinWaitActive("outfile1.pdf - Adobe Reader","","") Send("^q") ;Close Adobe Reader ;Wait for the window to not exist WinWaitClose("outfile1.pdf - Adobe Reader","","") Link to comment Share on other sites More sharing options...
November Posted May 11, 2011 Share Posted May 11, 2011 Check WHILE and WEND commands. Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
hannes08 Posted May 11, 2011 Share Posted May 11, 2011 Hi lisehu, you can use ShellExecute() to open a PDF file directly.( Shellexecute("C:\data\outfile1.pdf") ) Use FileFindFirstFile, FileFindNextFile OR _FileListToArray to have a list of pdf file ready. As November already said, you'll need loops (WHILE ... WEND, FOR ... NEXT) to open all of the documents in one script. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
wakillon Posted May 11, 2011 Share Posted May 11, 2011 Or you can use some PDF to TXT command line tools... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
lisehu Posted May 12, 2011 Author Share Posted May 12, 2011 Hi Hannes,I'm not too good at scrpting. Can you teach me how to do it?Thanks!LisehuHi lisehu,you can use ShellExecute() to open a PDF file directly.( Shellexecute("C:\data\outfile1.pdf") )Use FileFindFirstFile, FileFindNextFile OR _FileListToArray to have a list of pdf file ready.As November already said, you'll need loops (WHILE ... WEND, FOR ... NEXT) to open all of the documents in one script. Link to comment Share on other sites More sharing options...
hannes08 Posted May 12, 2011 Share Posted May 12, 2011 $a_pdflist = _FileListToArray("C:\Data", "*.pdf") For $i = 1 To $a_pdflist[0] ShellExecute("C:\Data\" & $a_pdflist[$i]) WinWaitActive($a_pdflist[$i] & " - Adobe Reader") Send("!f") ;File Open Send("a") ;Save As Send("x") ;Text ; Wait for Save As Window to become active WinWaitActive("Save As","","") Send("!s") ;Save ; Wait for Adobe Reader to become active WinWaitActive("outfile1.pdf - Adobe Reader","","") Send("^q") ;Close Adobe Reader ;Wait for the window to not exist WinWaitClose("outfile1.pdf - Adobe Reader","","") Next Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
lisehu Posted May 12, 2011 Author Share Posted May 12, 2011 Works perfectly. Thank you very much, Hannes! $a_pdflist = _FileListToArray("C:\Data", "*.pdf") For $i = 1 To $a_pdflist[0] ShellExecute("C:\Data\" & $a_pdflist[$i]) WinWaitActive($a_pdflist[$i] & " - Adobe Reader") Send("!f") ;File Open Send("a") ;Save As Send("x") ;Text ; Wait for Save As Window to become active WinWaitActive("Save As","","") Send("!s") ;Save ; Wait for Adobe Reader to become active WinWaitActive("outfile1.pdf - Adobe Reader","","") Send("^q") ;Close Adobe Reader ;Wait for the window to not exist WinWaitClose("outfile1.pdf - Adobe Reader","","") Next Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now