Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Extract sub folder name from a full file path

Hi,

This is an example for a path that I have:

C:\decisioning\log\dcs\1\1\dcs_meta_data_20131126113434.csv


I need to compare the folder number highlighted in RED to a list.


how can I isolate the folder number?

I had a code written with FileName function but I know it doesn't work in regular script but only in load script.



regards,


Boris

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

try

subfield('C:\decisioning\log\dcs\1\1\dcs_meta_data_20131126113434.csv','\',-3) will return the second last directory

View solution in original post

3 Replies
Anonymous
Not applicable
Author

I am not sure if i understood your question, but, are you trying to achieve this in the expression or you are trying in the load script.

If in load script, you can use the subfield syntax to get the string.

Regards,

Aadil

mr_janne
Contributor III
Contributor III

Load *, filedir( ) as X from

C:\UserFiles\abc.txt

Will return 'C:\UserFiles' in field X in each
record read.

So you could use:

load subfield(filedir(),'\',5) as FolderNumber

Hope that helps!

regards.janne

Clever_Anjos
Employee
Employee

try

subfield('C:\decisioning\log\dcs\1\1\dcs_meta_data_20131126113434.csv','\',-3) will return the second last directory