Highlighted

Using file names as source text with a twist

New Here ,
Aug 30, 2020

Copy link to clipboard

Copied

I am creating a slideshow that contains photos of 207 people, each photo is named like this [last name, first name]

I know how to get a text layer to read the source/layer name so that I don't need to write each individual name, however, I am wondering if there's a way to re-write the expression to take the [first name] and put it first, ignore the "," and then put the [last name].

Adobe Community Professional
Correct answer by Tomas_Sinkunas | Adobe Community Professional

Here's a clean way to do that. Change targetLayer by pickwipping a layer you want to read the name from:

var targetLayer = thisLayer;
var namesArray = targetLayer.name.split(',');
var firstName = namesArray[1];
var lastName = namesArray[0];

firstName + ' ' + lastName;

 

Topics

Expressions, Scripting

Views

56

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

Using file names as source text with a twist

New Here ,
Aug 30, 2020

Copy link to clipboard

Copied

I am creating a slideshow that contains photos of 207 people, each photo is named like this [last name, first name]

I know how to get a text layer to read the source/layer name so that I don't need to write each individual name, however, I am wondering if there's a way to re-write the expression to take the [first name] and put it first, ignore the "," and then put the [last name].

Adobe Community Professional
Correct answer by Tomas_Sinkunas | Adobe Community Professional

Here's a clean way to do that. Change targetLayer by pickwipping a layer you want to read the name from:

var targetLayer = thisLayer;
var namesArray = targetLayer.name.split(',');
var firstName = namesArray[1];
var lastName = namesArray[0];

firstName + ' ' + lastName;

 

Topics

Expressions, Scripting

Views

57

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
Adobe Community Professional ,
Aug 30, 2020

Copy link to clipboard

Copied

sure it's possible, use this expression

A = thisComp.layer("Your Name").source.name.split(" ")[0];

B = thisComp.layer("Your Name").source.name.split(" ")[1];

S = ' ';

[B + S + A]

 

change the number inside the [] to get the word you want example 0 for the first word and 1 for the second word

the S variable used to add space between words 

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...
Guide ,
Aug 30, 2020

Copy link to clipboard

Copied

The naming is lastName, firstName, therefore, you better use:

 

... source.name.split(",")[...];

 

This way, you are splitting the name string at the comma.

 

*Martin

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...
Adobe Community Professional ,
Aug 31, 2020

Copy link to clipboard

Copied

Here's a clean way to do that. Change targetLayer by pickwipping a layer you want to read the name from:

var targetLayer = thisLayer;
var namesArray = targetLayer.name.split(',');
var firstName = namesArray[1];
var lastName = namesArray[0];

firstName + ' ' + lastName;

 

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...