the following script works only if your swatches are "Spots"
select your little squares before running
var fontSize = 20;
var spacing = 6;
var idoc = app.activeDocument;
var sel = idoc.selection;
for (j=0; j<sel.length; j++) {
var ipath = sel[j];
var itext = idoc.textFrames.add();
try {
var icolor = ipath.fillColor;
itext.contents = icolor.spot.name;
}
catch (e){
itext.contents = 'Convert to Spot';
}
itext.textRange.characterAttributes.size = fontSize;
itext.left = ipath.left + ipath.width + spacing;
itext.top = ipath.top - ipath.height/2+ itext.height/2;
}
North America
Europe, Middle East and Africa
Asia Pacific