0

I need to build a string containing the filenames of the 15 most recent files (by modification date) within a directory. Delimited only by a space:

file1.jpg file2.jpg file3.jpg

I'm using ImageMagick via command line. Here is what I currently have, but get an error number -1728:

tell application "Finder"
    set imageItems to every file of folder wallpaperPath
    set imageItems to the reverse of (sort imageItems by modification date)
    set concatFiles to ""
    repeat with n from 1 to 15
        set imageItem to item n of imageItems
        set imageName to the file name of imageItem
        set concatFiles to concatFiles & " " & imageName
    end repeat
end tell
do shell script "cd " & wallpaperPath & "; montage " & concatFiles & " -tile 3x5 -geometry 500x500+1+1 ~/Desktop/final.jpg"
3
  • 1
    Can you show us what you have tried? – AllInOne Jul 30 '15 at 14:28
  • What is the ultimate purpose of the list and what have you tried? What step are you have difficultly with? – Graham Miln Jul 30 '15 at 14:28
  • updated my post with a code snippet – daleyjem Jul 30 '15 at 14:39
1

Change the line,

    set imageName to the file name of imageItem

to

    set imageName to the name of imageItem

and it should work.

EDIT:

Couldn't help but notice that you are not quoting your file names. If any of them contain spaces, then you will have problems. Best to also change

    set concatFiles to concatFiles & " " &  imageName

to

    set concatFiles to concatFiles & " " & quoted form of imageName

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .