I'm not sure what you mean by previous specified folder. Is that the folder where the current active document is located?
Here's a script for listing the layers:
#target photoshop
var doc = activeDocument;
var layerList = [];
var idxList = [];
var layerSets = 0
try{doc.backgroundLayer}
catch(e){layerSets=1}
var loopStart = layerSets;
var layerListFirst = getLayerSetsData();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("targetLayersIndexes"));
r.putEnumerated(stringIDToTypeID("document"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var curList = executeActionGet(r).getList(stringIDToTypeID("targetLayersIndexes"));
var curLyrIdx = curList.getReference(0).getIndex() + loopStart;
layerList.reverse();
idxList.reverse();
for(var i=0;i<idxList.length;i++){
if(idxList[i] == curLyrIdx){
var cLayerSelc = i}
}
var dlg = new Window('dialog','Select Layer');
dlg.location = [500,100];
var dList = dlg.add('dropdownlist',undefined,layerList);
dList.selection = cLayerSelc;
dList.onChange = function(){
selectLayerByIndex (idxList[parseInt(this.selection)],false)
dlg.close()
//selectLayerByIndex (index, add)
}
dlg.show()
function getLayerSetsData()
{
//var count = 0;//set counter for multi-dimensional array
var lyrSets = [];
while (true)
{
ref = new ActionReference();
ref.putIndex(charIDToTypeID('Lyr '), layerSets);
try
{var d1 = executeActionGet(ref)}
catch (err){
break;
};
var c2t = function (s){return app.charIDToTypeID(s);};
var s2t = function (s){return app.stringIDToTypeID(s);};
var lyrSet = {};
lyrSet.name = d1.getString(c2t("Nm "));
lyrSet.type = d1.getInteger(s2t("layerKind"));
if(lyrSet.type !=13){
idxList.push(layerSets)
layerList.push(lyrSet.name);
}
layerSets++;
};
//return lyrSets;
};
function selectLayerByIndex(index, add) {
add = (add == undefined) ? add = false : add;
var ref = new ActionReference();
ref.putIndex(charIDToTypeID("Lyr "), index);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID("null"), ref);
desc.putBoolean(charIDToTypeID("MkVs"), false);
try {
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO);
} catch (e) {}
};