Le 4 avr. 2012 à 20:48, Neil Laubenthal a écrit :
On Apr 4, 2012, at 11:15 AM,4/4, KOENIG Yvan wrote:
Thanks; that compiles and works but only lets me choose a single file at a time using the choose file dialog. What would I need to change to allow me to select a bunch of files and drop them onto the script for sequential processing and/or use it as a Folder Action Script so I can batch process things?
I can read that script and understand how it's doing it's work; but not being much of a programmer or scripter it is far beyond what I could produce on my own. I've gotten pretty good at modifying/borrowing from other scripts over the years to cobble stuff together but have never really been able to do much from scratch.
Here is an enhanced one.
--[SCRIPT]
on run
doyourduty(choose file of type "com.adobe.pdf" with multiple selections allowed)
end run
on open droppedItems
doyourduty(droppedItems)
end open
on doyourduty(theItems)
repeat with anItem in theItems
tell application "System Events"
set {name:fileName, type identifier:typeID, class:itemClass, container:parentFolder} to disk item (anItem as text)
set isFolder to itemClass is folder
end tell
if isFolder then
tell application "Finder" to set itemList to items of anItem
doyourduty(itemList)
else
if typeID is "com.adobe.pdf" then
read anItem
my remplace(result, "/Creator 49 0 R /", "/Creator (ScanSnap Manager) /")
write result to anItem
end if
end if
end repeat
end doyourduty
--=====
(*
replaces every occurences of d1 by d2 in the text t
*)
on remplace(t, d1, d2)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to "" & l
set AppleScript's text item delimiters to oTIDs
return t
end remplace
--=====
--[/SCRIPT]