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