I have a table view that I would like to be able to sort according to the dropped files’ creation date.
Is that possible at all ?
Actually, what i’m trying to do here is to batch rename files sequentially, but i would like my script to sort them according to their creation date first … the sequential renaming works perfectly, but it sorts them randomly I think (not even by name order)
tell application "Finder"
set the_folder to (choose folder)--or whatever
set these_items to every item of folder the_folder
set these_items to (sort these_items by creation date)
end tell)
I’m using this code snippet in another script in order to circumvent Mac’s propensity to automatically sort in “drop order”.
I did find this code example online before posting here, but I think I need to put that code in the on drop handler of my application.
Unfortunately, it doesn’t seem to work (which is why I resorted to posting here in the first place).
See, the items dropped on my app are contained in a variable called theTableViewContents. That variable is what i use to fill in the table contents.
and since it is a list, I don’t think it can be sorted that easily.
Unless I find a way to make a table view that the user can sort according to his needs… I need to keep searching.
(now that I think of it, I’ll have a look at the applescript example in the developer folder, i might find what I want or at least something close !)
OK, so I managed to implement a table sort in my table view thanks to the developer examples – so when i click a column it reorders the dropped items just fine.
However, the items are not processed in the order chosen (ie corresponding to the column clicked).
I think I would need to sort the content of the variable containing the items too, right ?
Does anyone know what code I need to add so that the items are renamed according to the table sort?