This version will let you select as many files as you wish, after you have made your selections press the "Select the selected" button.
#target bridge;
onDocLoadEvent = function( event ){
if(event.object instanceof Document){
if( event.type == "loaded" ){
$.sleep(1000);
keyCount();
}
}
return { handled: false };
}
app.eventHandlers.push( { handler: onDocLoadEvent} );
function keyCount(){
try{
sPalette = new TabbedPalette( app.document, "KeyTest", "test", "script","left","bottom");
pnl1 = sPalette.content.add('panel');
pnl1.alignChildren="left";
pnl1.addBtn = pnl1.add('button', undefined, 'Process');
pnl1.txtF = pnl1.add('edittext', undefined, " ");
pnl1.addBtn.preferredSize=[150,25];
pnl1.selBtn = pnl1.add('button', undefined, 'Select the selected');
pnl1.selBtn.preferredSize=[150,25];
pnl1.txtField = pnl1.add('listbox', undefined, undefined, { multiselect: true } );
pnl1.txtField.preferredSize=[200,200];
//should work but doesn't blame Adobe!
pnl1.txtField.graphics.font = "dialog:24";
pnl1.addBtn.onClick = function(){
pnl1.txtField.text ="";
var thumbs = app.document.visibleThumbnails;
var List =[];
var tCount =0;
for(var a in thumbs){
if(!thumbs instanceof File) continue;
var md = thumbs.synchronousMetadata;
try{
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
var count = md.Keywords.length;
tCount += count;
List.push([[decodeURI(thumbs.spec.name)],[count]]);
}catch(e){}
}
List = List.sort(function(a,b){return a[1]-b[1];});
List.reverse();
pnl1.txtF.text = "Total Keyword Count = " + tCount.toString();
pnl1.txtField.removeAll();
for(var z in List) {pnl1.txtField.add("item",List.toString());}
pnl1.selBtn.onClick=function(){
app.document.deselectAll();
var sels = pnl1.txtField.selection;
for(var r in sels){ app.document.select(new Thumbnail(app.document.presentationPath + "\\" +sels.toString().split(",")[0])); }
} }
sPalette.content.layout.layout(true);
}catch(e){$.writeln(e + "\n" + e.line);}
};