old AppleWorks script failing under 10.5
old AppleWorks script failing under 10.5
- Subject: old AppleWorks script failing under 10.5
- From: KOENIG Yvan <email@hidden>
- Date: Wed, 6 Aug 2008 18:49:19 +0200
Hello
Some years ago, I wrote a script exporting AppleWorks 6 WP document
as .doc.
It works under 10.4.11.
Alas, under 10.5, the unique instruction really used to export
doesn't change the kind of file.
It is saved with the .doc extension but it is an AppleWorks WP document.
May you try to help me to repair this annoying feature?
--[SCRIPT AWWP2Office8]
(*
Exécuter ce script
ouvre un documents TdT AppleWorks
et l'enregistreSous en fichier Office
dans le dossier "wasBOBO_nowOffice" sur le bureau.
Run the script
opens an AppleWorks WP
and save it as Office file
in the folder "wasBOBO_nowOffice" on the desktop.
Yvan KOENIG le 11 juin 2004
modifié le 12 juin 2004
étendu le 13 juin 2004
modifié le 14 juin selon suggestions de Hiroto TAOKA
traité bug AW6, (merci Hiroto) le 15 juin 2004
modifié le 17 juin 2004
modifié le 18 juin 2004
modifié le 19 juin 2004
modifié le 25 novembre 2004
modifié le 3 décembre 2004
*)
property Stockage : "wasBOBO_nowOffice"
property cheminDeStockage : "" -- globale
-- ===========
(* deux lignes exécutées si on double clique
sur l'icône du script application
• two lines executed if one double click
the application script's icon *)
set aFile to choose file with prompt msg00 of type {"CWWP"}
set cheminDeStockage to my creeDossierDeStockage()
my TraiteUnFichier(aFile as text)
-- ============= Routines
on creeNomUnique(dossier_, nom_, extension_)
set {suffixe, i} to {extension_, 1}
set {laFin, chemin_} to {suffixe, ""}
repeat
try
set chemin_ to "" & dossier_ & nom_ & laFin
chemin_ as alias (* un fichier de même nom existe-t-il ?
si oui (pas d'erreur) incrémenter l'index *)
set i to i + 1
set laFin to space & "#" & i & suffixe
on error (* s'il n'existe pas (erreur) c'est bon. *)
exit repeat
end try
end repeat
return nom_ & laFin
end creeNomUnique
-- =============
on enregistreSous(fichier_, traducteur_, chemin_)
tell application "AppleWorks 6"
activate
save document 1 in file chemin_ ¬
using translator traducteur_
end tell -- to AppleWorks
repeat 10 times
try
tell application "Finder" to update file chemin_
set existe to true
on error
set existe to false
end try
if existe is true then exit repeat
end repeat
tell application "Finder" to get properties of file chemin_ (* to
check if export behaved correctly *)
end enregistreSous
-- =============
on creeDossierDeStockage()
(* S'il n'existe pas,
construit un dossier destination sur le bureau
• If does not exist,
create a destination folder on the desktop *)
set cheminDuBureau to (path to desktop)
if Stockage ends with ":" then set Stockage to ¬
(text 1 thru -2 of Stockage) as text
set cheminDeStockage_ to ¬
"" & cheminDuBureau & Stockage & ":"
try
cheminDeStockage_ as alias
on error (* cheminDeStockage n'existe pas, on le crée
• cheminDeStockage is not available, build it *)
tell application "Finder" to ¬
make new folder at cheminDuBureau ¬
with properties {name:Stockage}
end try
return cheminDeStockage_
end creeDossierDeStockage
-- ===========
on TraiteUnFichier(leFichier)
tell application "Finder" to set ¬
leVraiNom to (name of alias leFichier)
if leVraiNom ends with ".cwk" then ¬
set leVraiNom to ¬
(text 1 thru -5 of leVraiNom) as text
(* • strip .cwk extension *)
tell application "AppleWorks 6"
try
open alias leFichier
end try
end tell -- to AppleWorks
set C to my createDirTree(cheminDeStockage, "")
(* ici il faut créer un nom unique *)
set nouvoNom to my creeNomUnique(C, leVraiNom, "doc")
set nouveauChemin to C & nouvoNom
my enregistreSous(leFichier, "Word 98, 2001 Mac", nouveauChemin)
tell application "AppleWorks 6" to ¬
close document 1 without saving
end TraiteUnFichier
-- ===========
on createDirTree(rc, p)
(*
string rc : root container path where to start directory tree
string p : path string such as "aaa:bbb:ccc:"
return string (rc & p) : path to created directory, such as
"rc:aaa:bbb:ccc:"
*)
try
(rc & p) as alias
return (rc & p) -- rc & p is already present
on error --
end try
try
set AppleScript's text item delimiters to ":"
set cc to text items of p
set AppleScript's text item delimiters to ""
set cc to items 1 thru -2 of cc
on error
set AppleScript's text item delimiters to ""
return rc
end try
set x to rc
repeat with C in cc
try
set y to x & C & ":"
y as alias -- check its presence
set x to y
on error
tell application "Finder" to ¬
set x to ¬
(make new folder at item x ¬
with properties {name:C}) as text
end try
end repeat
return x
end createDirTree
-- =============
--[/SCRIPT]
Thanks in advance.
Yvan KOENIG (from FRANCE mercredi 6 août 2008 18:49:15)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden