Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

To extract folder and subfolder names

Hi,

I have requirement to extract the folder name and its subfolder name in Qlikview script.

The folder structure will be like below

Main Folder

     SubFolder1 (the folder name will be date format. For eg., 20121001)

          InnerSubFolder (the folder name will be in time format (24-hrs) appended by the name. For eg., 210125 - Invoice (HH:MM:SS))

          ...........

     SubFolder2

     .......

So in this till Main Folder the path is constant. I need to fetch the SubFolder1, SubFolder2,.... and InnerSubFolder,... paths dynamically in Qlikview script.

Under SubFolder we have many InnerSubFolders in that I need to take a particular folder based on the appended text as in above example I need to check for Invoice folder. Inside the 210125-Invoice folder I have text document and that text document will be the source file.

An Example:

To get the text document placed at *Invoice folder

Main Folder = c:\Sample\test\

SubFolder = 20120928, 20120929,20120930, 20121001

InnerFolder = 102345-Order,034546-Inventory,210125-Invoice

In this need to loop through all the SubFolders and inside those SubFolders need to check for the folders Invoice it can be prefixed with any time and need to use the text file inside those Invoice folders.

Thanks in Advance.

Thanks,

Leni Balakrishnan

13 Replies
Anonymous
Not applicable
Author

Hi Rob,

Thanks for your answer

I have added the above lines @ script and when I tried to load, I am getting script line error

What the Include statement has?? How can I add the same in my application.

Could you explain the above code??

Regards,

Leni

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

The include statement includes the Qvc runtime script. You can download it at the url given above.

-Rob

Anonymous
Not applicable
Author

Hi,

Thanks.

Using your above logic I got the full path of the file.

Thanks a lot

Thanks,

Leni

rlp
Creator
Creator

You can use negative arguments with Subfield so that Subfield( <string> , <delimiter> -1 ) gives you the last part of the string. You can so obtain the filename with Subfield( _ , '\' , -1 ) and the subfolder with -2.