Re: finding newest file in a folder
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.