• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Contributor ,
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

391

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

Community Expert , 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
...

Votes

Translate

Translate
Community Expert ,
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

 

Votes

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
Contributor ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

Thanks for the script and the helpful links!

Votes

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
Community Expert ,
Nov 13, 2020 Nov 13, 2020

Copy link to clipboard

Copied

LATEST

You're welcome!

Votes

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