cancel
Showing results for 
Search instead for 
Did you mean: 

Download all files from SFTP to a folder

mtran21
New Contributor III

Hi, I want to download all the files in a remote SFTP server to the Files folder. I think this is a pretty simple task but I am new, so I am not sure what to do.
So I am thinking of using these 2 snaps
image

but I have problem about the output file names. If on my remote server has file1.txt, file2.txt, file3.txt then I want to download the exact file names to my files folder.

What do I put in the file name?
image

Thanks

1 ACCEPTED SOLUTION

The output file should be decrypted already, but with the encrypted filename.$['content-location'] will be the url of the encrypted file because File Writer is connected to PGP Decrypt.

You could replace or append the file extension if you know what the original extension is.

  • .replace('pgp', 'txt')
  • + ".txt"

View solution in original post

3 REPLIES 3

siwadon
Employee
Employee

You could use the following expression to get the filename from the input header.
$['content-location'].substr($['content-location'].lastIndexOf('/') + 1)

$['content-location'] represents the absolute path of the input file and the expression will remove everything from the beginning to the last forward slash.

mtran21
New Contributor III

Thanks for your help @siwadon

If I want to decrypt all the encrypted files from FTP server before I download them to my files folder, I added the Decrypt snap as below
image

but when I run it, the downloaded files are still with extension PGP. They are not decrypted.

How do I decrypt them?

The output file should be decrypted already, but with the encrypted filename.$['content-location'] will be the url of the encrypted file because File Writer is connected to PGP Decrypt.

You could replace or append the file extension if you know what the original extension is.

  • .replace('pgp', 'txt')
  • + ".txt"