Hi Garry,
You can get all the properties of a file through this script:
tell application "Finder"
set this_file to document file "XXXX.rtf" of path to your file get {properties} of this_file end tell
On looking at these properties you can select from a list similar to this:
{{class:document file, name:"XXXX", index:7, displayed name:"XXXX.rtf", name extension:"rtf", extension hidden:false, c*****, kind:"Rich Text Format (RTF) document", label index:0, locked:false, description:missing value, comment:"", size:9434.0, physical size:1.2288E+4, creation date:date "Thursday, 8 December 2005 5:38:42 AM", modification date:date "Thursday, 8 December 2005 5:38:42 AM", icon:missing value, U owner privileges:read write, group privileges:read only, everyones privileges:read only, file type:missing value, creator type:missing value, stationery:false, product version:"", version:""}}
It will just be a factor of selecting the data that has not been lost, perhaps kind, and replacing that in the above script. The example below would correct a missing extension if the file was a rich text file and the kind of the file was undamaged.
tell application "Finder" set this_file to document file "XXXX.rtf" of PATH TO THE FILE get {kind} of this_file
if kind of this_file is "rtf" and name extension of this_file is "" then set name extension of this_file to ".rtf" end if end tell
Peter Baxter
Music creates order out of chaos: for rhythm imposes unanimity upon the divergent, melody imposes continuity upon the disjointed, and harmony imposes compatibility upon the incongruous.
-- Yehudi Menuhin
|