• 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: finding newest file in a folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: finding newest file in a folder


  • Subject: Re: finding newest file in a folder
  • From: Deivy Petrescu <email@hidden>
  • Date: Sun, 14 Mar 2004 11:15:58 -0500

At 5:06 PM +1100 3/14/04, John Cochrane wrote:
Hello scripters.

I am trying to get a reference to a file that I have just scanned in to a folder. My scanning software won't get it for me so I thought I would try to identify it by finding the file of the 'scan_folder' whose creation date is latest.
I think a repeat loop is needed but can't seem to get it right.
I'd appreciate any pointers.

John Cochrane


John, if you do not mind you can use a straight forward method, shell script.
This requires no repeat:

<script>
set d to POSIX path of (path to "docs" as Unicode text)
set AppleScript's text item delimiters to ASCII character 13
set k to text item 1 of (do shell script " ls -t -1 " & d) as Unicode text
set AppleScript's text item delimiters to {""}
display dialog k
</script>

I am using the user document folder in this example, change it to whatever you need.
ls -t-1 outputs file in chronological order, newest first and 1 outputs only the name per line.
I did not compare speeds.
--
Regards
Saudagues

Deivy
http://www.dicas.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: finding newest file in a folder
      • From: Christopher Nebel <email@hidden>
References: 
 >finding newest file in a folder (From: John Cochrane <email@hidden>)

  • Prev by Date: Suggestion: iTunes needs a refresh event
  • Next by Date: What to do when strings don't match but should?
  • Previous by thread: Re: finding newest file in a folder
  • Next by thread: Re: finding newest file in a folder
  • Index(es):
    • Date
    • Thread