Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Dayna
Creator II
Creator II

Extracting a filename from a location string

Hello All,

Could you advise on the best method to extract information from a string? I'm looking to get the information of the filename, but the string comes through with the folder location aswell as the filename (and filetype). Ideally, the only piece of information I want is the filename.

The below shows some example data, as you can see the number of folders may change as does the length of the string and the fileattachment.

C:\Temp\Folder1\Outbound\filename1.xml

C:\Temp\Folder2\Outbound\filename_test1.xml

C:\Temp\Folder1\Inbound\filename_test2.txt

C:\Temp\Folder3\Outbound\filename2.xlsx

C:\Temp\Folder1\Outbound_Test1\data1.doc

C:\Temp\Folder2\Outbound_Test2\filename11.docx

C:\Temp\Folder2\Dev\Outbound\filename12.xml

C:\Temp\Folder4\Live\Inbound\filename31.xml

C:\Temp\Folder4\Dev\2601\Outbound\Customer1\filename41.xml

So for "C:\Temp\Folder4\Dev\2601\Outbound\Customer1\filename41.xml" I would like the result of "filename41".

Any help you could provide would be great!

Kind Regards,

Dayna

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi Dayna,

Another option:

Mid( 'C:\Temp\Folder4\Dev\2601\Outbound\Customer1\filename41.xml' , Index('C:\Temp\Folder4\Dev\2601\Outbound\Customer1\filename41.xml', '\', -1) +1) , '.', 1) 

Hope that helps.

Miguel

View solution in original post

1 Reply
Miguel_Angel_Baeyens

Hi Dayna,

Another option:

Mid( 'C:\Temp\Folder4\Dev\2601\Outbound\Customer1\filename41.xml' , Index('C:\Temp\Folder4\Dev\2601\Outbound\Customer1\filename41.xml', '\', -1) +1) , '.', 1) 

Hope that helps.

Miguel