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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
ganeshK
Contributor
Contributor

How to check particular prefix files exist or not inside directory

Hi,

I wanted to check particular prefix files are exist inside directory or not. If exist i want to perform some operation.

Tried with tFileexist -> It is checking only fully qualified file name. I want to check file exist or not with particluar prefix.

Tried with tFileList -> It is listing all files taking too much time. Simply i wanted to check is there any file exist with particular prefix.

Example:

Folder contains 1_filename1, 1_filename2, 1_filename3 , 2_filename1, 2_filename2, 2_filename3 etc..

I want to check is there any file exist with 2_*

Regards,

Ganesh.R

Labels (2)
3 Replies
gjeremy1617088143

Hi maybe you can do this :

 

in a tJava

 

-- in advanced settings :

 

import java.io.File;

 

-- in basic settings:

 

File dir = new File("here your directory path");

Boolean fileExist = (dir.listFiles(file -> file.getName().matches("^2_.*"))).length>0;

 

 

send me love and kudos

 

ganeshK
Contributor
Contributor
Author

Hi @guenneguez jeremy​ , Thanks for the solution and worked for me.

gjeremy1617088143

If my answer helped you, can you select it as best answer to close the ticket ?