Unable to download ALL files from a given folder

Advertisement

leewilmott
Joined:
Posts:
7

Unable to download ALL files from a given folder

I hope you can help.

I am using .NET script for WinSCP v5.15.19.

I am trying to download ALL files from the '/home/folder/inbox.app/Payments/FPS' folder on an SFTP Server.

I want to download all the files and delete them once they have downloaded. As a result I am using the following command...

$session.GetFiles('/home/folder/inbox.app/Payments/FPS/*', 'C:\LocalFolder\', $true, $transferOptions)

I would expect this to download all the files in the folder and then delete all the files it has successfully downloaded.

I have tried the following:
$session.GetFiles('/home/folder/inbox.app/Payments/FPS/', 'C:\LocalFolder\', $true, $transferOptions)

This 'kind of' works (ie. it downloads all my files), but it deletes the "FPS" folder - which I don't want to do.

Am I doing anything wrong?

Many thanks,

Lee

Reply with quote

Advertisement

leewilmott
Joined:
Posts:
7

Please ignore this topic!

Please ignore this topic...

I found out the issue. I was executing $session.FileExists($source) prior to calling the GetFiles function. The FileExists() method doesn't return true if the source contains files but path is a wildcard (ie. "folder/*"). As a result I removed the FileExists() method.

Thanks again,

Lee

Reply with quote

Advertisement

You can post new topics in this forum