tFTPDelete - Is it NOT possible to delete all files (from the server) but still keep the folder?

Highlighted
Six Stars

tFTPDelete - Is it NOT possible to delete all files (from the server) but still keep the folder?

I wanted to delete the files from a remote folder and I used the tFTPDelete component. Here is the configuration for it:

0914.PNG  

 

Basically, I wanted to empty this folder but KEEP the folder still. Initially, I put "*" on filemask and the job failed, and below is the error code:

Exception in component tFTPDelete_3 (movefiles)
24: This request cannot be used to remove a directory
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846)
at com.jcraft.jsch.ChannelSftp.rm(ChannelSftp.java:1958)

 

Then I put a new filemask ( shown above), all the files match that pattern except one .zip file. I ran the job again and the files were deleted, only .zip was left in the folder.

 

BTW, both times the Target Type was "File".

 

I am thinking - does tFTPDelete not allow us to empty a folder if we choose "File" as Target Type?

Seven Stars JGM
Seven Stars

Re: tFTPDelete - Is it NOT possible to delete all files (from the server) but still keep the folder?

You're right -- the Target Type will control what jsch method will be called ( ChannelSftp.rm() for files and ChannelSftp.rmdir() for directories ).

you may find some success with this approach:
first attempt to delete all the files. uncheck die on error in the first tFTPDelete component. connect another tFTPDelete with a onComponentError connector and then try to delete the directories.
Six Stars

Re: tFTPDelete - Is it NOT possible to delete all files (from the server) but still keep the folder?

JGM,

Thanks for your quick response, here is what I observed:

 

1. 0914-1.PNG 

Even though "Die on error" was unticked, the job still wouldn't run, it would just stop:

This request cannot be used to remove a directory
[statistics] disconnected

 

 

2. Only one component is needed to delete the files and directory:

0914-2.PNG

 

 

 

My question still is :  how to delete the files and still keep the folder on remote server? Is that possible?

Six Stars

Re: tFTPDelete - Is it NOT possible to delete all files (from the server) but still keep the folder?

I think I get the answer to my own question. Smiley Very Happy

 

If I want to delete all the files from a folder but still keep the directory, I will need to use specific file mask(s) which would delete all the files, but the file mask shouldn't be "*". 

For example, if I have below files in a folder, I should use file mask "Testfile_*" and "file_*" to delete all the files.

Testfile_001.xlsm

Testfile_002.xlsm

file_001.xlsm

file_002.xlsm

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.

 

Thirteen Stars

Re: tFTPDelete - Is it NOT possible to delete all files (from the server) but still keep the folder?

@TigerMommy,yes you can use the data mask from the tFTPList.

 

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

Manohar B