- Dec
- 57
- 3
@INSTR[start,[length],string]
I've been using the @instr function for a long time to extract part of a filename when I have a lot of files I want to rename. Works great, no problem. But I can't figure out how to work backwards from the end of the filename, which the documentation says is supported:
"If length is negative, the offset is measured leftward from the right end of the string, and its length is specified by the value of length without the minus sign."
The example given in the documentation is fine for a single string of a known length, but I have lots of files of various lengths with a certain string at the end I don't want. For example, I might have:
filename abcd.jpg
another filename abcd.jpg
a different filename abcd.jpg
the longer weird filename abcd.jpg
something else again abcd.jpg
some really different long weird name abcd.jpg
and another even longer unimportant filename abcd.jpg
....and so on...
And I want to rename them all without the abcd at the end. But I've never figured out how to make this work. Or is there a different function that would be better for this other than @instr.
I've been using the @instr function for a long time to extract part of a filename when I have a lot of files I want to rename. Works great, no problem. But I can't figure out how to work backwards from the end of the filename, which the documentation says is supported:
"If length is negative, the offset is measured leftward from the right end of the string, and its length is specified by the value of length without the minus sign."
The example given in the documentation is fine for a single string of a known length, but I have lots of files of various lengths with a certain string at the end I don't want. For example, I might have:
filename abcd.jpg
another filename abcd.jpg
a different filename abcd.jpg
the longer weird filename abcd.jpg
something else again abcd.jpg
some really different long weird name abcd.jpg
and another even longer unimportant filename abcd.jpg
....and so on...
And I want to rename them all without the abcd at the end. But I've never figured out how to make this work. Or is there a different function that would be better for this other than @instr.