• 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: Finder weirdness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder weirdness


  • Subject: Re: Finder weirdness
  • From: Walter Bushell <email@hidden>
  • Date: Thu, 11 Nov 2010 19:50:19 -0500

Thanks, coercing to an alias (by going to a string first) seems to work, so this
-----
tell application "Finder"
	activate
        -- x is scratch variable
	set x to POSIX file "/Users/Walter/Music/x0000.aif" as string
	set x to x as alias
	name of x
end tell
-------------
or even
-------------
 tell application "Finder" to name of ((POSIX file "/Users/Walter/Music/x0000.aif" as string) as alias)
-- one line of course
----------------------------------------

I want to start with POSIX files for two reasons:

That's the form I get the name when I drop a test file onto my script and I want to avoid spelling mistakes.

I am getting my file names in my real script from a Eunuchs "find" command.

But what I found (with out going around Robin Hood's barn as above) is that regardless the finder won't find my test file, I can see it in the Finder window and drop it on Quicktime Player, but when I try to reference it in Finder then Finder throws an error. Other files with the same methodology work and I don't know why. Perhaps they are too small?

The example I gave was a test case and I used "info for" because "get name' threw an error.
On Nov 11, 2010, at 1:43 PM, Stockly, Ed wrote:

> Walter,
>
> I Found it difficult to decipher both your message and your script.
>
> We may be able to help if you clearly state what you're trying to do and
> what's not working.
>
> In the meantime, here's a few pointers.
>
> Aliases are more reliable than any other file specifier, especially when
> scripting the Finder.  The alias will point to the same file even after its
> name has changed. (That may be what is throwing off your script, but it's
> hard to tell.)
>
> Your script uses the Finder to get the name of the file and the name of the
> info of the file.  No need for the 'info for' part. That's a call to an
> Osax, and provides the same information as the Finder call. In total your
> script asks for the name of the file four times. In my version the script
> gets the name of the file one time and does all the manipulations on that
> value outside of the finder tell block, which is more efficient.
>
> It may help to use more descriptive variable names. If you have a lot of
> Unix experience that may seem odd, but in appleScript it helps.
>
> The script below may help point you in the right direction,
>
> HTH,
>
> ES
> ----------
>
> tell application "Finder"
>    set myFile to (alias "MacOSX:Users:edstockly:Desktop:YourBrain 000.pdf")
> end tell
> --tell application "QuickTime Player" to open x
> log myFile
> my dostuff(myFile)
>
> on dostuff(myFile)
>    tell application "Finder"
>        set fileName to the name of myFile
>    end tell
>    set YfileName to "y" & text -7 thru -5 of fileName
>    set XfileName to "x" & text -7 thru -5 of fileName & ".pdf"
>    tell application "Finder"
>        set the name of myFile to YfileName
>        log the name of myFile
>        set the name of myFile to XfileName
>        log the name of myFile
>    end tell
> end dostuff
>
>
>
> On 11/11/10 9:55 AM, "Walter Bushell" <email@hidden> wrote:
>
>> set x to (POSIX file "/Users/Walter/Music/YourBrain 000.pdf")
>> --tell application "QuickTime Player" to open x
>> tell application "Finder"
>> log x
>> my dostuff(x)
>> end tell
>>
>> on dostuff(x)
>> set y to name of (info for x)
>>
>> tell application "Finder"
>> set the name of x to "y" & text -7 thru -5 of y & ".pdf"
>> set name of x to "x" & text -7 thru -5 of name of x & ".pdf"
>> end tell
>> end dostuff
>>
>

--
A unix salesperson, Lenore/Loved her job, but loved the beach more. She devised a way to combine work and play:/She sells C-shells by the seashore

 _______________________________________________
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

  • Follow-Ups:
    • Re: Finder weirdness
      • From: "email@hidden" <email@hidden>
    • Re: Finder weirdness
      • From: Deivy Petrescu <email@hidden>
References: 
 >Re: Finder weirdness (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: Finder weirdness
  • Next by Date: Re: Finder weirdness
  • Previous by thread: Re: Finder weirdness
  • Next by thread: Re: Finder weirdness
  • Index(es):
    • Date
    • Thread