OK, but what if I said it's a bad choice, because (a) it doesn't match the Finder's sort order, and (b) it doesn't match the Finder's hide/show extension preference? And that you can handle both and still be as fast,
if not faster?
use AppleScript version "2.4" --
Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
tell application "Finder"
set winTarget to insertion
location as alias
set finderSelectionList to selection as alias
list
if finderSelectionList = {} then
beep
return
end if
set byName to name of sort
column of list view options of Finder window 1 is name
column
if byName then
set reverseOrder to sort
direction of sort column of list view options of Finder
window 1 is not normal
set itemName to name of (last item of finderSelectionList)
end if
end tell
set newItemName to ""
if byName then
-- get full name so Finder extension setting doesn't matter, nor use of slashes
set lastItemPath to POSIX
path of (last item of finderSelectionList)
set lastItemPath to current
application's NSString's stringWithString:lastItemPath
set itemFullName to lastItemPath's lastPathComponent()
-- list folder and sort the same way as Finder
set itemNames to (current
application's NSFileManager's defaultManager()'s contentsOfDirectoryAtPath:(POSIX
path of winTarget) |error|:(missing
value))'s sortedArrayUsingSelector:"localizedStandardCompare:" -- sorted like Finder
if reverseOrder then set itemNames to itemNames's reverseObjectEnumerator()'s allObjects()
-- get index of the item
set theIndex to itemNames's indexOfObject:itemFullName
set theCount to itemNames's |count|()
-- there are more after it, so try to select the next one
if theIndex < theCount + 1 then set newItemName to (itemNames's objectAtIndex:(theIndex +
1)) as text
end if
tell application "Finder"
--
move finderSelectionList to destinationFolder
delay 0.05
try
tell front window to select item newItemName of winTarget
end try
end tell