• 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: "Stockly, Ed" <email@hidden>
  • Date: Thu, 11 Nov 2010 12:43:37 -0600
  • Acceptlanguage: en-US
  • Thread-topic: Finder weirdness

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
>

 _______________________________________________
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: "Mark J. Reed" <email@hidden>
    • Re: Finder weirdness
      • From: Walter Bushell <email@hidden>
References: 
 >Finder weirdness (From: Walter Bushell <email@hidden>)

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