Hello,
Thanks for your reply. It is very helpful.
The script from Yvan Koenig is his 'AW save As 6' script. I hope he will excuse my calling him the Frenchman. I meant no disrespect only that I had forgotten his name at the moment I was typing. I show it below.
With your explaination I now see that he was just parsing long file names that get truncated. The first file name I tried just happened to truncate just before one of the long endings that I thought meant something. The meaning of these endings is still a question.
-- [SCRIPT AW save As 6]
-- -------------------------------------
(*
ExŽcutez ce script,
le document AW au premier plan nommŽ monDoc
sera enregistrŽ sous le nom monDoc´0001
ˆ l'appel suivant sous monDoc´0002
puis monDoc´0003 É
En fin de session, aprs avoir vŽrifiŽ que le dernier
exemplaire est lisible, vous pourrez jeter les prŽcŽdents
Peut s'utiliser:
- depuis le bureau,
- depuis le menu Scripts d'AppleWorks
- tre associŽ ˆ un bouton.
Il existe mme un utilitaire permettant d'associer une
application (pourquoi pas celle-ci) ˆ une touche de fonction.
Run this script,
the front AW document will be saved as
myDoc´0001
then myDoc´0002
then myDoc´0003
When the session is done, check that the last copy is OK.
If it is you may trash the lower ones.
One may call it:
- from the desktop
- from AppleWorksÕs Scripts menu
- from a linked button.
There is an utility allowing us to link an application
(why not this one) to a function key.
Yvan KOENIG
le 24 avril 2004 ˆ Vallauris (France)
modifiŽ le 29 avril 2004
*)
-- -------------------------------------
property french : true -- true = franais, false = anglais
property extension : ".cwk"
property Borne : "´" -- surtout PAS le diese #
property ellipsis : ASCII character 201
property msg0 : ""
property msg1 : ""
property msg2 : ""
property msg99 : ""
on run
try
set vieuxDelim to AppleScript's text item delimiters
if msg0 is "" then my prepareMessages()
tell application "AppleWorks 6"
activate
set laVersion to version as text
if ("6." is not in laVersion) then Â
error msg0 number 8000
(* Ce script n'est pas compatible
avec cette version dÔAppleWorks.
¥ This script is not compatible
with this version of AppleWorks. *)
if (count each document) < 1 then Â
error msg2 number 8002
(* "Aucun document ouvert"
¥ "No open document" *)
set leChemin to (file of front document) as text
if leChemin is "false" then error msg1 number 8001
(* cas d'un fichier d'une "ancienne version"
¥ Take care of documents issued from old AW*)
tell application "Finder"
activate
try
set laFamille to ""
set laFamille to (label index of file leChemin) as text
end try
end tell -- to Finder
if my quelOS() is true then
tell application "Finder"
activate
set leDossier to (container of file leChemin) as text
(* fonction disponible dans OSX, pas dans OS9
¥ available in OSX, not in OS9 *)
end tell -- to Finder
else
set AppleScript's text item delimiters to ":"
set maListe to text items of leChemin
set item -1 of maListe to ""
set leDossier to (maListe) as text
set AppleScript's text item delimiters to vieuxDelim
end if
set nom1 to (name of front document) as text
if nom1 ends with extension then
set nom2 to text 1 thru -(1 + (count of extension)) of nom1
(* garde ce qui prŽcde
¥ keeps what is before the extension. *)
set avecExtension to true
else
set nom2 to nom1
set avecExtension to false
end if
if ((count of nom2) > 20) and (character 21 of nom2 is "#") then Â
set nom2 to (text 1 thru 20 of nom2) & ellipsis
(* raccourci les noms LONGs affichŽs sous la forme
"VeryVeryLongFileName#131B92.cwk"
¥ shortens LONG names displaid as
¥ "VeryVeryLongFileName#131B92.cwk" *)
if nom2 contains Borne then
set posiBorne to offset of Borne in nom2
set debut to text 1 thru posiBorne of nom2
set vieuxNum to text (posiBorne + 1) thru -1 of nom2
try
set nouveauNum to vieuxNum + 1
(* gŽnre une erreur si ce qui suit borne n'est pas un nombre *)
on error
set nouveauNum to 1
end try
else
if (count of nom2) > 22 then Â
set nom2 to (text 1 thru 21 of nom2) & ellipsis
(* pour rester dans la limite de 31 caractres
¥ to stay in the 31 characters range *)
set debut to nom2 & Borne
set nouveauNum to 1
end if
set nouveauChemin to my Â
quelChemin(debut, nouveauNum, avecExtension, leDossier)
tell front document
save nom1 in nouveauChemin
if not (laFamille = "") then
tell application "Finder"
activate
try
set label index of file nouveauChemin to laFamille
end try
end tell -- to Finder
end if
end tell -- to front
end tell -- AppleWorks
on error MsgErr number NroErr
if NroErr is not -128 then
beep 2
tell application (path to frontmost application as string) to Â
display dialog "" & NroErr & " : " & MsgErr with icon 0 Â
buttons {msg99} giving up after 20
end if
set AppleScript's text item delimiters to vieuxDelim
return
end try
end run
-- ------------------------------------- Routines
on quelChemin(leDebut, nouvoNum, avExtension, dossier)
tell application "Finder"
repeat
set nouvoNom to Â
leDebut & text -4 thru -1 of ("0000" & nouvoNum)
if avExtension is true then Â
set nouvoNom to nouvoNom & extension
set nouvoChemin to "" & dossier & nouvoNom
if exists file nouvoChemin then
set nouvoNum to nouvoNum + 1
else
exit repeat
end if
end repeat
end tell -- to Finder
return nouvoChemin
end quelChemin
-- -------------------------------------
on quelOS()
tell application "Finder"
set versionOS to version as text
if "10." is in versionOS then
set forX to true
else
set forX to false
end if
end tell
return forX
end quelOS
-- -------------------------------------
on prepareMessages()
if french is true then
set msg0 to "Ce script nÕest pas compatible" & return & Â
"avec cette version dÕAppleWorks." & return & Â
"Veuillez utiliser une version 6.x É"
set msg1 to Â
Â
"Document crŽŽ par une ancienne version dÕAppleWorks." & return & "Il faudrait lÕenregistrer au format AW6."
set msg2 to "Aucun document ouvert"
set msg99 to "ÊVuÊ"
else
set msg0 to "This script is not compatible" & return & Â
"with this version of AppleWorks." & return & Â
"Please use version 6.x ..."
set msg1 to Â
Â
"Document created with an old AppleWorks." & return & "Save it once as AW6."
set msg2 to "No open document"
set msg99 to "ÊOopsÊ"
end if
end prepareMessages
-- [/SCRIPT]