Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
JavierP2
Contributor
Contributor

Move (cut) files instead copy ftp to local folder

Hi there,

 

I'm working on a program that moves files between a SFTP server and a local folder.

 

It works fine but I have a problem, seems as the tFTPGet copy the files from the SFTP and move them to the local folder but the files still remain into the SFTP. I do need to cut the files instead copy, is there any way?

 

I've tried with a tFTPDelete but this solution doens't work 100% as is for example during the process between the FTPGet and the tFTPDelete a new file comes it auto deletes as is on the SFTP and it's not copied.

 

So solutions that I think that can work:

 

1) Cut the files instead copy 

2) Any rule into the tFTPDelete to only delete the ones listed into the tFTPFileList

 

Any ideas?

 

0683p000009M9sN.png

Thanks a lot!

Labels (2)
1 Solution

Accepted Solutions
billimmer
Creator III
Creator III

you should connect each subjob.  So connect

 

tFTPFileList_1 to tFTPFileList_2 with a OnSubjobOK

tFTPFileList_2 to tFTPFileList_3 with a OnSubjobOK

tFTPFileList_3 to tFTPFileList_4 with a OnSubjobOK

tFTPFileList_4 to tFTPClose_1 with a OnSubjobOK

 

 

View solution in original post

17 Replies
billimmer
Creator III
Creator III

This works for me:

 

tFTPFileList-----(iterate)---->tFTPGet----(componentOK)---->tFTPDelete

 

Delete the files as you get them.

JavierP2
Contributor
Contributor
Author

thanks for the reply.

the thing is that I have other works before the delete so in that time that the work runs the system can generate other file (i've tested it) so in any way I need to ensure that it only delete the ones already copied. 

billimmer
Creator III
Creator III

Why not download the files and then do your 'other work' on the local copies?

 

If the 'other work' has to be on the ftp server, then rename the files, and do the other work on the renamed copies.

JavierP2
Contributor
Contributor
Author

Rename the names make sense, I've tried before with tFTPRename but I don't know how to rename the files keeping the same name but adding some extra at the begining, like a OK_+"FILENAME" any idea how to do that?

 

If I put "" into the newname (on the tFTPRename) it keeps the same but cannot add the OK_ at the begininnig.

 

Thanks !

billimmer
Creator III
Creator III

don't you have the name from your tFTPFileList for use in your tFTPGet?  Maybe

 

"OK_" + ((String)globalMap.get("tFTPFileList_1_CURRENT_FILE"))

 

JavierP2
Contributor
Contributor
Author

Thanks for the reply.

 

Tried to put it after the FTPGet but it shows me this error:

 

Exception in component tFTPRename_1 (MOVEORDERSDV)
3: Permission denied

 

Do I have to declare something into the tFTPlist?

0683p000009MA74.png

billimmer
Creator III
Creator III

try in the filemask:

 

((String)globalMap.get("tFTPFileList_1_CURRENT_FILE")) 

 

instead of

 

"*"

 

To rename just that file.

 

Also, I would rename it first, and then "get" the copy.

billimmer
Creator III
Creator III

Also, I don't understand why you are using a OnSubjobOK with your tFTPFileList, and then have 4 tFTPGet's.  That implies that you "know" the file names and don't need the tFTPFileList to get the file names.  

 

I mention this because the ((String)globalMap.get("tFTPFileList_1_CURRENT_FILE")) is only going to be the last file if finds, because it's used after the OnSubjobOK.

 

sorry, I just don't understand what you are trying to do.

JavierP2
Contributor
Contributor
Author

It works but only with the first file, If I move more than 1 it only renames the first one.