• 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: Another tedious newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another tedious newbie question


  • Subject: Re: Another tedious newbie question
  • From: Rob Jorgensen <email@hidden>
  • Date: Mon, 8 Apr 2002 19:40:56 -0400

On 4/8/02, Christopher Coulon commented:

Sorry for the simple question, but I did spend some time unsuccessfully
trying to get the answer.

I am experimenting with AppleScript Studio and am programming a button to
start a search for an image. I use the script:

try
someFile as alias
on error
set someFile to choose file
end try

Which essentially gives me what I want, i.e., someFile is the file selected
and its path.

My question: how do I separate the file (a tiff image) from its path? I
want to get the file's name and use the path to store results from
processing the image, so I would like one variable to contain the file's
name and another to be the path to the file's folder. However, I don't want
the user to do more than one search to get both pieces of information.

Your variable "someFile" will contain the path in the form of an alias, so these will provide the path and name.

-- Begin Sample #1 -- Uses "info for" from Standard Additions to get file name

try
someFile as alias
on error
set someFile to choose file
set fileName to name of (info for someFile)
end try

-- End Sample #1 --


-- Begin Sample #2 -- Uses AppleScript's text item delimiters to get file name

try
someFile as alias
on error
set someFile to choose file
try
set oldTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set fileName to last text item of (someFile as text)
set AppleScript's text item delimiters to oldTIDs
on error
set AppleScript's text item delimiters to oldTIDs
end try
end try

-- End Sample #2 --

--
Best regards,

Rob Jorgensen
Ohio, USA
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Another tedious newbie question (From: Christopher Coulon <email@hidden>)

  • Prev by Date: Re: Quark 4 & 5 Xpress tags
  • Next by Date: Re: Quark 4 & 5 Xpress tags
  • Previous by thread: Another tedious newbie question
  • Next by thread: Re: Quark 4 & 5 Xpress tags
  • Index(es):
    • Date
    • Thread