Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I have a string with different file names at the end.
Once
D:\Data\3423.jpg
and then
D:\Data\999934.JPG
or also
D:\Data\4545.JPG
How can I get only the numerical value 3423, 999934 or 4545?
I have no more ideas!!!
Thank you very much and all the best!
If it is only digits and no digits in the folder structure then you can get the desired result by using keepchar()
Try this: KeepChar([Your string], '1234567890')
You can also do the more generic solution fetching the name using subfield(subfield())
SubField(SubField([YourString], '\',-1),'.',1)
In case your directories might include numbers as well, you could use something like:
table1:
LOAD *,
SubField(SubField(Path,'\',-1),'.',1) as Number
Inline [
Path
D:\Data\3423.jpg
D:\Data\999934.JPG
D:\Data\4545.JPG
D:\PathWithNumber6789\12345.JPG
];
hope this helps
Marco
Hi and thank you!
It works with "SubField" - BUT, what can I do, if I want the ImageFileName, like
3423.jpg
999934.jpg
or also 3343_3.jpg (new Case).
Than, SubField dosn't work.
What can I do?
Hi @sroettger
Try like below:
SubField(Path,'\',-1)
Subfield will work even if it's new case like mentioned 3343_3.jpg
SubField() still would work to also implement this new requirement, but you could as well use Mid() and Index() to extract the string following the last '\' delimiter, i.e. the file name including extension:
table1:
LOAD *,
SubField(Path,'\',-1) as File,
Mid(Path,Index(Path,'\',-1)+1) as File2
Inline [
Path
D:\Data\3423.jpg
D:\Data\999934.JPG
D:\Data\4545.JPG
D:\PathWithNumber6789\12345.JPG
D:\Data\999934.jpg
D:\Data\3343_3.jpg
1234_5.jpg
];
hope this helps
Marco