• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Script to replace lost file extension
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Script to replace lost file extension


  • Subject: Re: Script to replace lost file extension
  • From: Peter Baxter <email@hidden>
  • Date: Wed, 25 Apr 2007 12:10:05 +1000

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
email@hidden

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

iChat email@hidden


 _______________________________________________
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

References: 
 >Script to replace lost file extension (From: "Simon, Garry" <email@hidden>)

  • Prev by Date: Simple Date-Time Format Question...
  • Next by Date: silly frontmost question
  • Previous by thread: Re: Script to replace lost file extension
  • Next by thread: Re: Script to replace lost file extension
  • Index(es):
    • Date
    • Thread