(1) It seems that you never used a template.
'Opening' a template create a new document which was never saved so when you will save it you will be asked to give it a name and even to define the wanted location exactly as you did with Save As….
It's why in such a case the menu item is named "Save…"
(2) You don't have to write a script, I wrote it. Here it is
--{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
*)
--=====
property add_TM : false
(*
true = insert the character ™ at the end of the filename
false = leave the name untouched
*)
property un_document : ""
--=====
on run
set un_document to ((choose file without invisible) as text)
run scriptmain
end run
--=====
script main
(*
Use the property un_document *)
local type_id
tell application "System Events" to set type_id to type identifier of disk item un_document
if type_id is "com.apple.iwork.keynote.key" then
(*
Convert a Keynote document *)
tell application "System Events" to tell disk item un_document to set name to (text 1 thru -4 of (get name) & "kth")
else if type_id is "com.apple.iwork.numbers.numbers" then
(*
Convert a Numbers document *)
tell application "System Events" to tell disk item un_document to set name to (text 1 thru -8 of (get name) & "nmbtemplate")
else if type_id is "com.apple.iwork.pages.pages" then
(*
Convert a Pages document *)
tell application "System Events" to tell disk item un_document to set name to (text 1 thru -6 of (get name) & "template")
else if type_id is in {"com.apple.iwork.keynote.kth", "com.apple.iwork.numbers.template", "com.apple.iwork.pages.template", "com.apple.rtfd"} then
(*
Skip Keynote, Numbers, Pages templates as well as rtfd documents *)
set un_document to ""
error number -128
else
tell application "System Events"
try
tell disk itemun_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 storage property *)
set un_document to ""
end script
--=====
on open sel
set un_document to (first item of sel) as text
run scriptmain
end open
--=====
--[/SCRIPT]
--{code}
Yvan KOENIG (VALLAURIS, France) jeudi 8 septembre 2011 19:02:05
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
My iDisk is : <http://public.me.com/koenigyvan>
Please : Search for questions similar to your own before submitting them to the community