• 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: last modified file - how to catch?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: last modified file - how to catch?


  • Subject: Re: last modified file - how to catch?
  • From: Luther Fuller <email@hidden>
  • Date: Mon, 07 Jul 2014 11:54:18 -0500

On Jul 7, 2014, at 9:21 AM, Omar K N wrote:

But when applying to the path here, I cannot write the correct path in the 1st line:

set _path to POSIX path of (path to folder "_Output" of folder "Documents" of home as text)
set lastModifiedFile to first paragraph of (do shell script "ls -Ft " & quoted form of _path & " | sed -E '/\\/$/d'")

I tried this, with modifications, and got these scripts that do work.
First ...

property folderAlias : alias "Work_Files:Mail Archives:Mail-Safe Archive:2014:7:3"
tell application "Finder"
(sort files of folderAlias by modification date)
end tell
item 1 of the result as alias --> the alias to the most recent file in the folder folderAlias


Second ...

property folderAlias : alias "Work_Files:Mail Archives:Mail-Safe Archive:2014:7:3"
set AppleScript's text item delimiters to {return}
quoted form of (POSIX path of folderAlias)
do shell script "ls -Ft " & the result & " | sed -E '/\\/$/d'"
text item 1 of the result --> name of the most recent file
tell application "Finder"
(item (the result) of folder folderAlias) as alias --> the alias to the most recent file in the folder folderAlias
end tell

Starting and ending a script with aliases is safe and avoids problems.
Hope this helps.



 _______________________________________________
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: last modified file - how to catch?
      • From: "koenig.yvan" <email@hidden>
References: 
 >Re: Re: last modified file - how to catch? (From: Omar K N <email@hidden>)

  • Prev by Date: Re: last modified file - how to catch?
  • Next by Date: Re: last modified file - how to catch?
  • Previous by thread: Re: last modified file - how to catch?
  • Next by thread: Re: last modified file - how to catch?
  • Index(es):
    • Date
    • Thread