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

Using file names as source text with a twist

New Here ,
Aug 30, 2020 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].

TOPICS
Expressions , Scripting

Views

272

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

Advocate , Aug 31, 2020 Aug 31, 2020

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;

 

Votes

Translate

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

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

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
Advocate ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

LATEST

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;

 

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