Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
smathew2949
Contributor III

subfolder delete using tftp

I am trying to delete all the subfolder and file using tftpfiledelete but none of the option seems to be working and throws an error Below is the screenshot of the setup.I need to traverse all the sub directories and delete each file and folder under the parent directory. Any help would be appreciated

0695b00000PKc9fAAD.png

Labels (3)
6 Replies
Anonymous
Not applicable

Hello,

What the error are you getting when you are trying to delete all the sub-folder?

The tFTPDelete component uses 3rd party libraries (such as package com.enterprisedt.*) which doesn't allow deleting non-empty ftp directories.

However it's possible to achieve this with a routine which does this 'recursively'.

Best regards

Sabrina

smathew2949
Contributor III
Author

It gives me below exception

Exception in component tFTPDelete_1 (abc)

4: /temp/csv

at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2873)

at com.jcraft.jsch.ChannelSftp.rmdir(ChannelSftp.java:2149)

at test.tFTPDelete_1Process(test.java:1630)

at test.angfedpm.tFileList_4Process(test.java:14109)

at test.run(test.java:16809)

 

I agree if the folders are not empty it does not allow to delete the folder however in my case i have many such subfolder let us at runtime there would be sub-folder with name as timestamp eg.

 

csv

  • 112345678
    • a1.csv
    • a2.csv
  • 645755757
    • b1.csv
    • b2.csv

so i wont know how to iterate through all and delete the files under them before the deleting the folder

 

For the routine do you have sample to share

 

Appreciate your help

Anonymous
Not applicable

Hello,

The Target Type will control what jsch method will be called ( ChannelSftp.rm() for files and ChannelSftp.rmdir() for directories ).

As long as specific file mask(s) is used to delete all the files, it doesn't matter Target Type is "File" or "Directory", it would only delete the files and always keep the directory.

 Only the file mask "*" + Target Type "Directory" combination would delete the directory.

 

For your use case, you will need to use specific file mask(s) which would delete all the files, but the file mask shouldn't be "*" and you can use the data mask from the tFTPList. 

tFTPList--Iterate-->tFTPDelete and use the global parameter from FTPList in FTPDelete.

Let us know if it helps.

Best regards

Sabrina

smathew2949
Contributor III
Author

tFTPList--Iterate--tFTPDelete would not work in my case since i have many subfolder which i would need to iterate and delete all the files under how can i do this i haven't found a way yet to do this please let me know

Anonymous
Not applicable

Hello,

Would you mind giving us some example about your many sub-folder structure? Does the combination of tFTPDelete_1-->OnComponentOK-->tFTPDelete_2 helps?

Best regards

Sabrina

smathew2949
Contributor III
Author

In my case number of sub folder is not fixed based on certain condition it may vary . can you share a screenshot for tFTPDelete_1-->OnComponentOK-->tFTPDelete_2 and helpme understand what will the firsttFTPDelete_1 will do and what will be the role of tFTPDelete_2