Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Talend_ent
Contributor III
Contributor III

Deleting folders which are empty

Hi everyone,

I've a requirement to delete all the folders and sub-folders which are empty i.e folders with out files.

 

I tried with this tFilelist --> tFileExist --> tFileDelete with their respective global variables but nothing worked for me and workaround please suggest me.

 

Thanks in advance.

Labels (3)
1 Reply
Anonymous
Not applicable

Hi

I would use one tFileList to iterate directory, and use another tFileList to iterate files in the current direcotry (including the sub-directory). There is a global variable ((Integer)globalMap.get("tFileList_1_NB_FILE")) that counts the total number of files found, if it is 0, means the directory is empty. The job looks like:

tFileList--iterate--tRunJob

 

tRunJob: call the child job, and pass current directory path to child job, please refer to

https://help.talend.com/reader/HavZ1pLN5PZ~FuTJY51TEQ/root

 

child job:

tFileList--iterate--tJava

|runIf--tFileDelite

 

Set the condition of runIf as:

((Integer)globalMap.get("tFileList_1_NB_FILE")) ==0

 

Please try and let me know if it works.

 

Regards

Shong