Looking for a JSFL script to prefix layers names with numbers in the timeline

Participant ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

I need this to only run on layers in the active/open timeline and not go diving into symbols, etc.

 

So for example, the layers…

Man

Woman

Dog

Background

 

Would change to…

01 Man

02 Woman

03 Dog

04 Background

 

I found this in the Illustator forum, and I assumed the syntax would be similar but I can't get it to work.

 

var docRef = app.activeDocument;
with (docRef) {
     for (var i = 0; i < layers.length; i++) {
          layers.name = layers.length - i;
     }
}

 

Any help is appreciated!

TOPICS
How to, Other, Timeline

Views

104

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Nov 13, 2020 Nov 13, 2020
Hi.   Save this script in a .jsfl file using any text editor and execute it. Pleace notice that this script will prompt you to turn off the advanced layers mode first because layers cannot start with numbers in this mode.   var dom = fl.getDocumentDOM(); var timeline = dom.getTimeline(); var layers = timeline.layers; var turnOffAdvancedLayers; function main() { turnOffAdvancedLayers = confirm("For this script to work, the advanced layers mode needs do be turned off first. Do you want to conti...

Likes

translate

Translate

Translate
Adobe Community Professional ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

Hi.

 

Save this script in a .jsfl file using any text editor and execute it. Pleace notice that this script will prompt you to turn off the advanced layers mode first because layers cannot start with numbers in this mode.

 

var dom = fl.getDocumentDOM();
var timeline = dom.getTimeline();
var layers = timeline.layers;
var turnOffAdvancedLayers;

function main()
{	
	turnOffAdvancedLayers = confirm("For this script to work, the advanced layers mode needs do be turned off first. Do you want to continue?");
	
	if (!turnOffAdvancedLayers)
		return;
	
	timeline.advancedLayersEnabled = false;

	layers.forEach(function(layer, index)
	{
		layer.name = zeropad(index, 2) + " " + layer.name;
	});
}

function zeropad(number, length) {
   
    var str = '' + number;
	
    while (str.length < length)
		str = '0' + str;
   
    return str;
}

main();

 

Learn more about scripting with JSFL and creating extensions for Animate in the following links:

https://www.adobe.io/apis/creativecloud/animate.html

https://www.adobe.io/apis/creativecloud/animate/docs.html

https://help.adobe.com/archive/pt_BR/flash/cs5/flash_cs5_extending.pdf

 

Regards,

JC

 

Likes

translate

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
community guidelines
Participant ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

Thanks for the script and the helpful links!

Likes

translate

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
community guidelines
Adobe Community Professional ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

You're welcome!

Likes

translate

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
community guidelines