Script for Open as Layer Without File Extension
I have been searching for a script to open an image and rename a background layer into the file name. I found the below script which works perfectly; however, I'd like to have the layer name without a file extension.
Can someone please help me with editing the script?
Your help will be much appreciated.
// (c) Copyright 2008. Adobe Systems, Incorporated. All rights reserved.
/*
@@@BUILDINFO@@@ OpenAsLayer.jsx 1.0.0.0
*/
var begDesc = "$$$/JavaScripts/OpenAsLayer/Description=Assign this to the open document event. This will promote a document with only a background layer to a layer with the document name." // endDesc
// on localized builds we pull the $$$/Strings from a .dat file, see documentation for more details
$.localize = true;
if ( app.documents.length > 0 ) {
var doc = activeDocument;
if ( doc.layers.length == 1 && doc.activeLayer.isBackgroundLayer ) {
doc.activeLayer.isBackgroundLayer = false;
var docNameNoExtension = doc.name;
if (stripExtension) {
var extensionIndex = docNameNoExtension.lastIndexOf (".");
if (extensionIndex != -1) {
docNameNoExtension = docNameNoExtension.substr(0, extensionIndex);
}
}
doc.activeLayer.name = docNameNoExtension;
}
}

