• 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: Change type/creator
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change type/creator


  • Subject: Re: Change type/creator
  • From: "Steven D.Majewski" <email@hidden>
  • Date: Wed, 22 Sep 2004 20:56:55 -0400


On Sep 22, 2004, at 7:59 PM, Steven D.Majewski wrote:


On Sep 22, 2004, at 5:33 AM, Michelle Steiner wrote:

On Sep 21, 2004, at 11:30 PM, Bernard Azancot wrote:

I would like to know how to write an applet which first reads type/creator from a first dropped document file and change a second dropped file's one.

The problem is that when you drop more than one file, you have no control over the order they appear in the list, so the script doesn't know which is supposed to be the first and which is supposed to be the second.

Noted above is the problem with the question as asked.

But another way to solve the problem, is to write both a run handler and an open
handler for the script. The run handler can set up properties ( for file type or
creator, for example ) with a dialog. The open handler changes the dropped files
according to the last settings of the property. ( That pattern is useful if you
need to run the file conversion script more often than you need to change the
default settings. )




Here's a quickly written (and minimally debugged) example to illustrate.
Save as an application.
Double clicking on the app icon runs the 'on run' handler.
Dropping files on the app icon runs the 'on open' handler.

-- Steve Majewski

------------------


property newType : missing value property newCreator : missing value

-- on run, set newType, newCreator from a chosen file
-- on open, set dropped files to newType, newCreator

on run {}
get {file type, file creator} of (info for (choose file))
set {tmpType, tmpCreator} to result
display dialog ("Change type/creator to : " & tmpType & "/" & tmpCreator & " ?")
if button returned of result is "OK" then
set my newType to tmpType
set my newCreator to tmpCreator
end if
end run


on open (alist)
if length of alist = 1 then
set setwhat to first item of alist as string
else
set setwhat to ((count of alist) as string) & " files"
end if

display dialog "set type creator of " & setwhat & " to: " & newType & "/" & newCreator & " ?"
if button returned of result is "OK" then
repeat with x in alist
tell application "Finder"
set theFile to file named (x as string)
set file type of theFile to newType
set creator type of theFile to newCreator
end tell
end repeat
end if

end open


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Change type/creator
      • From: Joseph Weaks <email@hidden>
References: 
 >Change type/creator (From: Bernard Azancot <email@hidden>)
 >Re: Change type/creator (From: Michelle Steiner <email@hidden>)
 >Re: Change type/creator (From: "Steven D.Majewski" <email@hidden>)

  • Prev by Date: Re: Change type/creator
  • Next by Date: Re: Change type/creator
  • Previous by thread: Re: Change type/creator
  • Next by thread: Re: Change type/creator
  • Index(es):
    • Date
    • Thread