Re: Finder - getting file type
Re: Finder - getting file type
- Subject: Re: Finder - getting file type
- From: DizzyPenguin <email@hidden>
- Date: Thu, 23 Dec 2004 09:23:50 +0000
On 23 Dec 2004, at 09:15, Paul Berkowitz wrote:
set existFile_wExt to (fullPath as Unicode text & coverName & ".jpg")
tell application "Finder" to set fType to (file type of alias existFile_wExt)
Isn't it safer to have the "as Unicode text" at the end, in case the coverName variable contains accented characters (here I go again with those!)?
No. The concatenation operator ('&') implicitly coerces the class of operand(s) on its right to the class of the leftmost operand. If you've already erroneously used string for coverName when you should have used Unicode it will be too late anyhow. If it's already Unicode, good: coercing fullPath to Unicode (if necessary) will preserve the Unicode of coverName and keep it Unicode when concatenating ".jpg" string to the end. Whereas if fullPath were string and then you concatenated coverName to it it would all change to string first and you'd lose the Unicode. It would make no difference that you then converted the resulting long string back to Unicode at the end - the characters would just be "Unicode versions' of the string characters, NOT the original Unicode. Of course, if fullPath is the path to a folder it should be in Unicode to begin with. If so, you don't need 'as Unicode text' at all. The first item fullPath is Unicode, the coverName hopefully is Unicode which will be preserved, and the whole thing including ".jpg" will be Unicode, with no need for explicit coercion at all.
When I started having problems related to Unicode text, I (sort of blindly) added "
as Unicode text" just about everywhere I could think of.
Your detailed explanation makes it all clearer to me now.
Thank you very much Paul.
And have a Merry Christmas!
Regards,
Guy
--
DizzyPenguin * autoMAC-it
email : <email@hidden>
website : <http://www.dizzypenguin.com/automac-it/>
_______________________________________________
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