try{ if ( app.documents.length > 0 ) { var doc = activeDocument; if ( doc.layers.length > 1){ var idslct = charIDToTypeID( "slct" ); var desc19 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref17 = new ActionReference(); var idLyr = charIDToTypeID( "Lyr " ); var idOrdn = charIDToTypeID( "Ordn" ); var idBack = charIDToTypeID( "Back" ); ref17.putEnumerated( idLyr, idOrdn, idBack ); desc19.putReference( idnull, ref17 ); var idMkVs = charIDToTypeID( "MkVs" ); desc19.putBoolean( idMkVs, false ); executeAction( idslct, desc19, DialogModes.NO ); } if ( doc.activeLayer.isBackgroundLayer == true ) { doc.activeLayer.name = doc.name + "_Background"; } } }catch(e){ alert('The command "Convert Background to Layer" is not currently available.'); }