Following the discussion we had in this thread, I wanted to re-introduce the Custom Script Converter.
Although the help center article gives some examples about how to use it, let’s all share in this thread your tips & tricks where this converter made your life easier.
I’ll start with the one that enables to trim a text on both hands, based on a fixed number of starting & ending characters to remove.
I believe I learned two ways to do this, one from @AlexL and the other from @Mihai I believe:
This one works best for all players, including tablets. (I think android values technically are not ‘blank’, that’s why the one below works best for those)
Is there any way to extract the file name from a file path, and add ", " (that’s comma,space) to it? I’m using this to track a list of picture-names that someone has selected using the Concatenate IA, and write it to one cell in Excel.
Currently I have a work around that is working (thanks to @Seb as always), but I’m hoping for something a little cleaner.
An example is this:
INPUT: D:\IntuiFace\MedMtgImages-PhotoSelector\Files\InterfaceAssets\FileSystemBrowsingJS\Images\18ADA_00001.jpg
DESIRED OUTPUT: 18ADA_00001.jpg,
It’s possible the number of characters in the file name could vary depending on the file. I was hoping there’d be a way to extract it by a delimiter, but there isn’t currently a selection for that type of slash “\”.
I couldn’t resist to answer you tonight on this one, since you’ll see as easy it can be, when you know how to write a little JavaScript
Here’s the code for your converter:
INPUT.substring(INPUT.lastIndexOf("\\")+1)
It basically finds the last index of the \ character in the INPUT string (still need to escape this special character, thus the \ in the code) and returns what’s after this index, +1 not to have the \ in the returned string.
Give it a try and confirm me it does what you were looking for
You’re awesome! I’ll give it a try and report back. Is there a way to build in a comma and a space after the last character too? That way it’ll look like a nice list when it gets written to the excel cell.
Would I just add ", " to it?
Quick explanation: the split command will break down the line into an array of elements, using “\” as separator. folder[X] will display the Xth element of this array and I use folders.length-2 to target the 2nd before the end in this array.
That’s a cool effect, @Promultis. I’d love to use that in IF someday. Thanks for sharing.
@Seb, I actually bought a beginners course some time ago, (on Udemy) but IF is keeping me too busy to go through the course! Haha, maybe that’s a good thing?