Reply To: Script to import partial filename

#92449
Omar Khatib
Member

Okay I guess I need to try it again.

I am trying the same thing but the filename is structured like this: page#_CatCode NotSoRandomNameVersion#.indd (i.e. 203_DS CouldBeAnything04.indd)

I want to capture the “CatCode” which could be 2-5 uppercase characters located after the first underscore and before the first space.

In the script above…

“fileNameVariable = app.activeDocument.name.split(“_”)[0]; // get XXXXX from XXXXX_Name1_Name2_Name3.indd file name
alert(fileNameVariable); // show XXXXX”

The split(“_”) splits the name with the underscore but how does it know to show the first instance? Can I split the name with and underscore and a space?

Can I do a grep find in Javascript?

Thank you in advance for the help!

This article was last modified on February 27, 2017

Comments (0)

Loading comments...