• 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: ASObjC: Get Most Recent File or Folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ASObjC: Get Most Recent File or Folder


  • Subject: Re: ASObjC: Get Most Recent File or Folder
  • From: Jim Underwood <email@hidden>
  • Date: Fri, 08 Jul 2016 23:55:57 +0000
  • Thread-topic: ASObjC: Get Most Recent File or Folder

Shane,

Thanks for the heads up.

This seems to work for checking for an empty folder:

if (theSortedNSArray as list is {}) then return ""


Best Regards,

Jim Underwood
aka JMichaelTX


From: <applescript-users-bounces+jmichael=email@hidden> on behalf of Shane Stanley <email@hidden>
Date: Fri, Jul 8, 2016 at 6:41 PM
To: "ASUL (AppleScript)" <email@hidden>
Subject: Re: ASObjC: Get Most Recent File or Folder

On 9 Jul 2016, at 8:50 AM, Jim Underwood <email@hidden> wrote:

      return (theSortedNSArray's lastObject()'s valueForKey:(current application's NSURLPathKey)) as text

Just be aware that if the folder is empty, firstObject() and lastObject() will return missing value, and you will get an error trying to call valueForKey: on missing value. So to be safe you should do some kind of check, perhaps getting the count of the array, first.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

References: 
 >Re: ASObjC: Get Most Recent File or Folder (From: Jim Underwood <email@hidden>)
 >Re: ASObjC: Get Most Recent File or Folder (From: Jim Underwood <email@hidden>)
 >Re: ASObjC: Get Most Recent File or Folder (From: Jim Underwood <email@hidden>)
 >Re: ASObjC: Get Most Recent File or Folder (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: ASObjC: Get Most Recent File or Folder
  • Next by Date: Re: Trouble Saving New PDFPenPro File
  • Previous by thread: Re: ASObjC: Get Most Recent File or Folder
  • Next by thread: Anything new in OSX 10.12 ?
  • Index(es):
    • Date
    • Thread