I work with a large number of Adobe Photoshop CS2 files, and it would improve my workflow a lot to have them open in reverse name order, so that, for example, 01 will be on the top and 20 on the bottom.
I found a couple of scripts online that may help, unfortunately I don’t know enough to edit them to make them work for me.
This should be easy, I would think. But it’s beyond me.
The script I’m trying to edit is:
(*
To compare on things OTHER than name, you can define your very OWN comparator function
as follows:
script MyComparator
on GreaterThan(f1, f2)
return true if f1 IS GREATER THAN f2 for whatever attributes you happen to be comparing
end GreaterThan
end script
Then, the call to InsertInList() will look like this:
set newList to InsertInList(newList, aFile, MyComparator)
*)
script NameComparator
on GreaterThan(f1, f2)
tell application "Finder"
set n1 to name of item f1
set n2 to name of item f2
end tell
return n1 > n2
end GreaterThan
end script
script ReverseNameComparator
on GreaterThan(f1, f2)
tell application "Finder"
set n1 to name of item f1
set n2 to name of item f2
end tell
return n2 > n1
end GreaterThan
end script
on open theFiles
set newList to {}
repeat with aFile in theFiles
-- Use ReverseNameComparator so we open the first file ("A") after the others ("B", "C"...)
set newList to InsertInList(newList, aFile, ReverseNameComparator)
end repeat
repeat with aDifferentFile in newList
tell application "TextEdit" to open aDifferentFile
end repeat
end open
on InsertInList(theList, theFile, theSortingComparator)
set listCount to number of items in theList
set theIndex to 1
repeat with theIndex from 1 to listCount
if (GreaterThan(item theIndex of theList, theFile) of theSortingComparator) then
-- When we find an item in the list > the item we wish to insert,
-- then we know we should insert the item at i.
exit repeat -- we just exit, and we'll use the value of theIndex to determine where to insert.
end if
end repeat
if (theIndex is 1) then
set theList to {theFile} & theList
else if (theIndex is listCount) then
set theList to theList & {theFile}
else
set theList to (items 1 thru (theIndex - 1) of theList) & {theFile} & (items theIndex thru listCount of theList)
end if
return theList
end InsertInList
Model: Dual 1.8 GHz Power PC G5
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
Hi,
if all you need to do is to reverse a list then something like this will do it!
set mylist to {1, 2, 3, 4, 5, 6, 7, 8, 9}
set mynewlist to {}
repeat with this_item in mylist
set mynewlist to this_item & mynewlist
end repeat
choose from list mynewlist
Hi,
the script below will get a list of every item in a folder of your choice it will then reverse that list and open the items in Photoshop.
Providing all the items in the folder are images that Photoshop can open, and your images are in the correct name order in the folder then it will open the first item in that folder last.
set source_folder to choose folder
tell application "Finder" to set mylist to every item of source_folder
set mynewlist to {}
repeat with this_item in mylist
set mynewlist to (this_item as alias) & mynewlist
end repeat
repeat with this_image in mynewlist
tell application "Adobe Photoshop CS2"
activate
open this_image
end tell
end repeat
I was envisioning selecting images in a window (say the first 25 out of a 100) and dragging them to a droplet and then they would open in order… but this will work for me… I’ll just divvy things up in a couple of sub folders.
AppleScript is hard!
Thanks so much!
Model: Dual 1.8 GHz Power PC G5
AppleScript: 2.1.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
Hi,
glad this helps.
Applescript does seem difficult to start with but once you’ve written a few, things start to fall into place.
If you need any further help then just let me know!
Thanks,
Nik