How to search folders for a similar by different filename?
Hello,
I'm writing a script to replace links in an InDesign file with images that have similar, but different file names.
So, suppose I have a set of links in a file with the following names:
- 100A_Apple.psd
- 200B_Orange.psd
- 300C_Banana.psd
And I want InDesign to find matching files in a folder to replace the links, but the codes are different (there is no logic to the numbers, so math won't work):
- 527X_Apple.psd
- 109Y_Orange.psd
- 845Z_Banana.psd
I'm using getFiles() to store file names from the folder in an array. Then I need to search that array for a matching file and return the file name so I can relink the image.
I've tried several methods to search the array for substrings, but none of them work. What I can glean from my research is that ExtendScript doesn't have access to higher order functions like filter(), find(), findIndex(), or includes(). So I probably have to write my own function, but that's where my coding skills start to falter. Any help?
