Anyone know how to do it? I’d rather not use Acrobat or GUI scripting in Preview, since it’s not scriptable.
Thanks,
Tim
Anyone know how to do it? I’d rather not use Acrobat or GUI scripting in Preview, since it’s not scriptable.
Thanks,
Tim
Maybe this is what you need.
#[SCRIPT batch lock PDFs]
(*
Enregistrer ce script en tant qu'application.
Exécuter ce script ou
déposer l'icône d'un dossier sur son icône.
Il verrouille les PDFs du dossier .
*************
Save the script as an application.
Run it or drag and drop a folder icon on its icon.
It lock PDFs embedded in the folder.
*************
Yvan KOENIG (VALLAURIS, France)
2014/01/12
*)
#=====
on run (*
lignes exécutées si on double clique sur l'icône du script application
¢ lines executed if one double click the application script's icon *)
tell application "SystemUIServer" to choose folder
my main({result as text}) # Pass a list of one pathname
end run
#=====
on open (sel) (*
sel contient une liste d'alias des éléments
qu'on a déposés sur l'icône du script (la sélection)
¢ files_list contains a list of aliases of the items
dropped on the script's icon (the selection) *)
my main(files_list)
end open
#=====
on main(files_list)
try
repeat with elem in files_list
try
my exploreTraite(elem as alias, "")
end try
end repeat
on error MsgErr number NroErr
if NroErr is not -128 then
beep 2
if my parleAnglais() then
"Oops"
else
"Oops"
end if
tell application "SystemUIServer" to display dialog "" & NroErr & " : " & MsgErr with icon 0 buttons {result} giving up after 20
end if # NroErr is.
return
end try
if my parleAnglais() then
"Treatment done."
else
"Traitement terminé."
end if
my afficheLeMessage(result)
end main
#=====
on afficheLeMessage(m)
beep 1
if my parleAnglais() then
"OK"
else
"Vu"
end if
tell application "SystemUIServer" to display dialog m buttons {result} default button 1 giving up after 10
end afficheLeMessage
#=====
on exploreTraite(elem, ptree) (*
elem est un alias
¢ elem is an alias *)
local elem_, cl_, typeId_
set elem_ to elem as text
tell application "System Events" to tell disk item elem_
set cl_ to its class
if cl_ is folder then
set typeId_ to ""
else
set typeId_ to type identifier
end if
end tell
set cl_ to cl_ as text
if cl_ is in {"folder", "«class cfol»"} then
my ExploreUnDossier(elem_, ptree)
else if typeId_ is "com.adobe.pdf" then (*
C'est un fichier PDF.
¢ It's a PDF file *)
my TraiteUnFichier(elem_)
end if # cl_ is .
end exploreTraite
#=====
on ExploreUnDossier(dossier, ptree)
local nomElement, cheminElement, C
# Would be safe to drop the use of list folder
repeat with nomElement in list folder dossier without invisibles
set cheminElement to dossier & nomElement
tell application "System Events" to set C to name of (dossier as alias)
my exploreTraite(cheminElement as alias, ptree & C & ":")
end repeat
end ExploreUnDossier
#=====
on TraiteUnFichier(p)
tell application "Finder"
set locked of (p as alias) to true
end tell
end TraiteUnFichier
#=====
on parleAnglais()
return (do shell script "defaults read 'Apple Global Domain' AppleLocale") does not start with "fr_"
end parleAnglais
#=====
#[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) dimanche 12 janvier 2014 16:30:22
Ahh, it’s the Finder’s job.
Merci beaucoup Yvan!