Topic "Ignore errors when downloading"

Author Message
sendo
[View user's profile]

Joined: 2014-01-16
Posts: 4
Hi guys,
Sorry if i missed something but does anyone know how to ignore errors when downloading ?
I have to download multiple files but the operation failed beacause i don't have permissions to access some files.
So i'm looking for a "continue with next" option
I tried to set ContinueOnError or PreserveReadOnly
I also tried :
Code:
try
{
 $transferResult = $Session.GetFiles($remotePath, $localPath, $false, $transferOptions)
}
catch {}


but the exception still raise and seem to be uncatchable.
Any ideas ?
(I'm using the last build with powershell)

Thanks
sendo
[View user's profile]

Joined: 2014-01-16
Posts: 4
too bad, batch continue option seems to be unsupported, so i will call getfiles for each file with something like that :


$excludeDir='|*/'
$directory = $session.ListDirectory("$remotePath")
foreach ($file in $directory.Files | where {-not $_.IsDirectory})
{
foreach ($f in $file)
{
$transferOptions.FileMask = $f.Name + $excludeDir
$transfer = $Session.GetFiles($remotePath, $localPath, $false, $transferOptions)
if ($transfer.Transfers.Error) {Write-Host ("{0} : {1}" -f $transfer.Transfers.FileName, $transfer.Transfers.Error) -ForegroundColor Red
}
}
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24995
Location: Prague, Czechia
sendo wrote:
too bad, batch continue option seems to be unsupported, so i will call getfiles for each file with something like that

That's the correct way.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License