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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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:

0683p000009M09W.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?

Labels (3)
4 Replies
Anonymous
Not applicable
Author

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.
Anonymous
Not applicable
Author

JGM,

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

 

1. 0683p000009Lzsa.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:

0683p000009M0GM.png

 

 

 

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

Anonymous
Not applicable
Author

I think I get the answer to my own question. 0683p000009MACJ.png

 

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.

 

manodwhb
Champion II
Champion II

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

 

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