Sorry, my previous email bounced (sent from wrong account) … this should also work
set all_the_Hires_Images to paragraphs of (do shell script "cd
" & qp & "&& ls -1t")
the numerical 1 tells ls to produce one filename per line
If you have ls aliased to produce fancy output, you may want to include the full path i.e. “&& /bin/ls -1t"
Enrique Terrazas
On Mar 12, 2014, at 1:21 PM, Enrique Terrazas < email@hidden> wrote:
Try this:
set all_the_Hires_Images to paragraphs of (do shell script "cd
" & qp & "&& ls -t | cat")
ls -t gives you a reverse sorted list by modification time
the pipe to the cat command is to produce a list with a single filename per line
Enrique Terrazas
On Mar 12, 2014, at 1:04 PM, Bert Groeneveld < email@hidden> wrote:
Hi Luther,
What I am looking for is speed. The image folder contains 25000 jpg files. And Mark's script returns a list of 25000 filenames in just a couple of seconds (even if the image folder is a network mount).
Your Finder script is much too slow (and it returns the full paths instead of only the filenames). I need speed, that's why I need the shell script instead of a Finder script. Unfortunately I really wouldn't know how to edit Mark's script in a way that
the list is sorted by modification date with the newest first (instead of alphabetically).
Anyway, thank you for your answer.
- - - - - - - - - - - - - - - - - -
On 12 mrt. 2014 (week 11), at 20:08, Luther Fuller < email@hidden> wrote:
This looked familiar, so I looked in an old script and found ...
set rawMsgList to (reverse of (sort {get items of sourceFolder} by modification date)) -- Leopard needs {}
So, I did some experimenting. Like this ...
property sourceFolder : alias "OS_X:Library:Application Support"
on run
tell application "Finder"
-- set fileList to sort (get items of sourceFolder) by modification date
set fileList to (reverse of (sort (get items of sourceFolder) by modification
date))
end tell
item 1 of fileList as text
log the result
end run
This seems to do what you need ... and does not need 'do shell script'.
(But, perhaps you had something else in mind that I overlooked. ?)
On Mar 12, 2014, at 10:06 AM, Bert Groeneveld wrote:
Thanks to Mark J. Reed I have following very, very powerful piece of code:
set all_the_Hires_Images to paragraphs of (do shell
script "cd " & qp & "&& find . -type f -print | sed -e 's,.*/,,'")
I use it this way:
set the_ImagePath_folder to choose folder with prompt "Choose Hires Folder"
set qp to quoted form of POSIX path of the_ImagePath_folder
set all_the_Hires_Images to paragraphs of (do shell script "cd " & qp &
"&& find . -type f -print | sed -e 's,.*/,,'")
(* Finder alternative (much slower)
tell application "Finder"
set all_the_Hires_Images to name of every file of entire contents of the_ImagePath_folder
end tell
*)
This script returns a list (sorted alphabetically) of the NAMES of all files inside a certain highres folder. So far so good.
What I need now is the same list, but than sorted by modification date with the newest files first (instead of sorted alphabetically). Is someone able to help me and edit Mark's code? I am unable to figure this out myself.
Thank you for any help, Bert.
|