Reply To: Script to import partial filename

#92453
Oleh Melnyk
Member

– how does it know to show the first instance?
fileNameVariable = app.activeDocument.name.split(“_”)[0] // < [0] means “first instance”

– Can I split the name with and underscore and a space?
sure, you can write any pattern to split: .split(” _”) or .split(“_ “) or whatever fits your needs

– Can I do a grep find in Javascript?
almost! you can do a regexp, which is simplified version of grep

– I want to capture the “CatCode” which could be 2-5 uppercase characters located after the first underscore and before the first space.
try this:
“page#_ABCDE NotSoRandomNameVersion#.indd”.match(/[A-Z]{2,5}(?=)/)[0] // should return “ABCDE”

This article was last modified on February 27, 2017

Comments (0)

Loading comments...