Hi,
first of all, sorry for my english, I hope you understand my question/problem. First of all, I’m new in scripting, so I’m not very experienced.
I have several difficulties with a folder action script. Perhaps I should explain the setup first. Here in my office I have a network-scanner witch stores files on a network-share. I tried to create a folder action script witch checks, whether there’s a new file and if so starts an oct-application.
The biggest problem is, that the scan-process can last a long time, especially when a larger document is scanned. So I need a check whether the file is used or not. The busy-status from the file info/system events doesn’t work, because the scanner doesn’t set the status.
So I wrote this script, witch worked very well
try
set this_item to "homeserver:SanDisk-CruzerBlade-01:scan.pdf"
--Abfrageschleife ob Datei benutzt wird, darin OCR-Aufruf
repeat 20 times
try
open for access file this_item -- wenn möglich, Datei nicht in Benutzung
close access result
ocr(this_item)
exit repeat
on error -- Datei in Benutzung
delay 3 -- Warte insgesamt 1 Minute 20 x 3
end try
end repeat
on error errText
display dialog "Error: " & errText
end try
end adding folder items to
-- OCR-Funktion
on ocr(scan_file)
tell application "ExactScan Pro"
activate
set profile to 11
open scan_file
delay 5 --warte kurz
repeat until processing is false
end repeat -- wird noch gearbeitet?
close scan_file
delay 5 --warte kurz
end tell
end ocr
Then I tried to make a folder action, but it doesn’t work and I’ve no idea why not. The folder action works, when I copy files to the folder and the check-process isn’t in the script, when I put the “open for access…” then it doesn’t work
on adding folder items to this_folder after receiving these_items
try
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
--Abfrageschleife ob Datei benutzt wird, darin OCR-Aufruf
repeat 20 times
try
open for access file this_item -- wenn möglich, Datei nicht in Benutzung
close access result
ocr(this_item)
exit repeat
on error -- Datei in Benutzung
delay 3 -- Warte insgesamt 1 Minute 20 x 3
end try
end repeat
end repeat
on error errText
display dialog "Error: " & errText
end try
end adding folder items to
-- OCR-Funktion
on ocr(scan_file)
tell application "ExactScan Pro"
activate
set profile to 11
open scan_file
delay 5 --warte kurz
repeat until processing is false
end repeat -- wird noch gearbeitet?
close scan_file
delay 5 --warte kurz
end tell
end ocr
So, if anybody has an idea it would be great.
Thanks a lot
Stefan