Highlighted

Script for layer naming

New Here ,
Oct 26, 2020

Copy link to clipboard

Copied

Does anyone have a script for putting the file name in the layer when I drag it into my document?

TOPICS
How to

Views

83

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script for layer naming

New Here ,
Oct 26, 2020

Copy link to clipboard

Copied

Does anyone have a script for putting the file name in the layer when I drag it into my document?

TOPICS
How to

Views

84

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 26, 2020 0
Adobe Community Professional ,
Oct 26, 2020

Copy link to clipboard

Copied

Can you list out step by step how you see this working?

 

Drag-n-drop is not very workable with a script... What if the script changed the source doc layer name to the document name, then when you dragged it over it would have the right name? But what would happen with the original layer name, should it then be reverted as a second step, would you do this manually or would a second script do this? 

 

I presume that the source doc should be the layer name, without filename extension?

 

How many files are open when you do this? Only one, or will this vary (and will the source doc vary in the list of open docs)?

 

Would another method that provided the same end result be acceptable (i.e. why not use place, or duplicate layer etc)?

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 26, 2020 1
New Here ,
Oct 26, 2020

Copy link to clipboard

Copied

Thanks for your reply

I wanted to have the file name in the layer when i open a doc. instead og Background.

Then when i drag my next image in as a layer i want it to have its file name. in full.

i had this on my old PS but i cant find the script i had.

My images can have upward of 4o image layers.

Myles

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 26, 2020 0
Adobe Community Professional ,
Oct 26, 2020

Copy link to clipboard

Copied

So, you are happy to have all images processed by the script have the full filename including extension replacing the original flattened Background "image" with the named layer.

 

That is pretty easy to script, I'll hack something together when I have free time. You'll need to use the script events manager to automatically run the script when you open files.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 26, 2020 0
New Here ,
Oct 26, 2020

Copy link to clipboard

Copied

Seriously! wow.

Thanks 

That would be amazing.

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 26, 2020 0
Adobe Community Professional ,
Oct 26, 2020

Copy link to clipboard

Copied

No need to write anything, this seems to be a common enough request!

 

https://jkost.com/blog/2010/09/open-make-and-rename-layer.html

http://www.jkost.com/scripts/OpenAsLayer.jsx.zip

http://blogs.adobe.com/jkost/files/2010/12/OpenAsLayerNoExtension.jsx_.zip

 

 

With File Extension:

 

 

// (c) Copyright 2008.  Adobe Systems, Incorporated.  All rights reserved.

/*
@@@BUILDINFO@@@ Open As Layer.jsx 1.0.0.1
*/

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
var begName = "$$$/JavaScripts/OpenAsLayer/MenuName=Open As Layer" // endName

// on localized builds we pull the $$$/Strings from a .dat file, see documentation for more details
$.localize = true;

try {

	if ( app.documents.length > 0 ) {
		var doc = activeDocument;
		if ( doc.layers.length == 1 && doc.activeLayer.isBackgroundLayer ) {
			doc.activeLayer.isBackgroundLayer = false;
			doc.activeLayer.name = doc.name;
		}
	}

} // try end

catch( e ) {
	// always wrap your script with try/catch blocks so you don't stop production
	// remove comments below to see error for debugging 
	// alert( e );
}

 

 

Without File Extension:

 

 

// (c) Copyright 2008.  Adobe Systems, Incorporated.  All rights reserved.

/*
@@@BUILDINFO@@@ OpenAsLayer.jsx 1.1.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;

var stripExtension = 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;
	}
}

 

 

or

 

https://community.adobe.com/t5/photoshop/renaming-a-layer-with-the-file-name/td-p/10531371?page=1

 

https://community.adobe.com/t5/photoshop/rename-background-layer-to-file-name-and-move-to-top/td-p/7...

 

https://community.adobe.com/t5/photoshop/background-layer-to-file-name-script/td-p/9741921?page=1

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 26, 2020 0
Adobe Community Professional ,
Oct 27, 2020

Copy link to clipboard

Copied

An alternative is to use the File > Scripts > Load Files Into Stack which does layer each file using the filename+extension. No need to drag-n-drop or alter the original image layer name etc.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 27, 2020 0