I want to write a script that will run my OCR software on each PDF file in a folder and its subfolders. I want it to check for new files every night.
My OCR software is fairly automatic in that it will accept a filename as an argument, then it will process that file, append "_OCR" to the filename, and exit.
How can I write a macro that will look for PDFs without OCR in the name, and then run the program on them?
Thanks!
Running a process on each file in a directory
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Something like this perhaps:
Code: Select all
Let>RP_WAIT=1
//get a list of pdf files in the folder
GetFileList>c:\somedir\*.pdf,file_list
//Explode that list into an array
Separate>file_list,;,files
//Loop through the array
Let>k=0
Repeat>k
Let>k=k+1
Let>this_file=files_%k%
//Only process this file if "OCR" is NOT in the filename
//These two lines get the filename part from the end of the full path
Separate>this_file,/,file_parts
Let>filename=file_parts_%file_parts_count%
//This returns the position of OCR in the filename, 0 if no match, in p
Pos>OCR,filename,1,p
If>p=0
//So OCR did not appear in filename, so run your software passing the file to it
Run>"YourOCRSoftware.exe" %this_file%
Endif
Until>k=files_count
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You may need:
run>"c:\ocrprogram.exe" "c:\testfile"
But show me the DOS line.
run>"c:\ocrprogram.exe" "c:\testfile"
But show me the DOS line.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?