Hello Peter
Here is a slightly enhanced version of a script already posted months ago.
I azdded support of the iBooks Author files.
--{code}
--[SCRIPT set_stationery]
(*
Enregistrer le script en tant que Script : set_stationery.scpt
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Utilisateurs:<votreCompte>:Bibliothèque:Scripts:
Aller au menu Scripts , choisir “set_stationery”
Naviguer pour sélectionner le document à convertir en modèle.
On peut également enregistrer en tant qu’application.
Dans ce cas,
double cliquer puis naviguer pour sélectionner le document à convertir en modèle.
ou
glisser déposer l’icône du document à convertir sur celle de l'application
Si vous définissez la property add_TM comme true, le caractère ™ sera inséré à la fin du nom du document converti pour faciliter son repérage.
--=====
L’aide du Finder explique:
L’Utilitaire AppleScript permet d’activer le Menu des scripts :
Ouvrez l’Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case “Afficher le menu des scripts dans la barre de menus”.
Sous 10.6.x,
aller dans le panneau “Général” du dialogue Préférences de l’Éditeur Applescript
puis cocher la case “Afficher le menu des scripts dans la barre des menus”.
--=====
Save the script as a Script: set_stationery.scpt
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:
Go to the Scripts Menu, choose “set_stationery”
Navigate then select the document to convert.
You may also save as an application.
In this case :
double clic the app’s icon to navigate then select the document to convert.
or
drag and drop the icon of the document to convert upon the app’s icon
If you set the property add_TM to true, the character ™ will be inserted at the end of the filename allowing you to quickly identify stationeries.
--=====
The Finder’s Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the “Show Script Menu in menu bar” checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2011/09/08
2012/01/01 added support of the alternate iWork's typeIDs
2012/04/18 added support of iBooks Author documents
*)
--=====
property add_TM : true
(*
true = insert the character ™ at the end of the filename
false = leave the name untouched
*)
property un_document : ""
--=====
script main
(*
Use the property un_document *)
local type_ID
tell application "System Events" to set type_ID to type identifier of disk item (my un_document)
if type_ID is in {"com.apple.iwork.keynote.key", "com.apple.iwork.keynote.sffkey"} then
(*
Convert a Keynote document *)
tell application "System Events" to tell disk item (my un_document) to set name to (text 1 thru -4 of (get name) & "kth")
else if type_ID is in {"com.apple.iwork.numbers.numbers", "com.apple.iwork.numbers.sffnumbers"} then
(*
Convert a Numbers document *)
tell application "System Events" to tell disk item (my un_document) to set name to (text 1 thru -8 of (get name) & "nmbtemplate")
else if type_ID is in {"com.apple.iwork.pages.pages", "com.apple.iwork.pages.sffpages"} then
(*
Convert a Pages document *)
tell application "System Events" to tell disk item (my un_document) to set name to (text 1 thru -6 of (get name) & "template")
else if type_ID is in {"com.apple.ibooksauthor.book", "com.apple.ibooksauthor.pkgbook"} then
(*
Convert an iBooks Author document *)
tell application "System Events" to tell disk item (my un_document) to set name to (text 1 thru -5 of (get name) & "template")
else if type_ID is in {"com.apple.iwork.keynote.kth", "com.apple.iwork.keynote.sffkth", "com.apple.iwork.numbers.template", "com.apple.iwork.numbers.sfftemplate", "com.apple.iwork.pages.template", "com.apple.iwork.pages.sfftemplate", "com.apple.ibooksauthor.template", "com.apple.ibooksauthor.pkgtemplate"} then
(*
Skip iBooks Author, Keynote, Numbers, Pages templates *)
set my un_document to ""
error number -128
else
tell application "System Events"
try
tell disk item (my un_document)
if not stationery then
set stationery to true
if add_TM then
(*
Optionally insert ™ at the end of the filename to easily recognize templates *)
set name_extension to name extension
if name_extension is "" then
set name to name & " ™"
else
set name to (text 1 thru -(2 + (count of name_extension)) of (get name) & " ™." & name_extension)
end if -- name_extension
end if -- add_TM
end if -- not stationery
end tell -- disk item…
end try
end tell -- System Events
end if -- type_id
(*
Clean the stored property *)
set my un_document to ""
end script
--=====
on run
set my un_document to ((choose file without invisible) as text)
run script main
end run
--=====
on open sel
set my un_document to (first item of sel) as text
run script main
end open
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) mercredi 18 avril 2012
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3
My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k