Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Problems downloading file with "]" character in name

Your code does not demonstrate the problem. You never use the $targetFileName variable. Also, the problem is left bracket ([), not right (]), right?

Anyway, in general, use RemotePath.EscapeFileMask:
https://winscp.net/eng/docs/library_remotepath_escapefilemask

Or use Session.GetFileToDirectory instead of Session.GetFiles.
https://winscp.net/eng/docs/library_session_getfiletodirectory

(don't use GiveUpSecurityAndAcceptAnySshHostKey, unless you understand and accept the security consequences).
arielbj

Problems downloading file with "]" character in name

Good afternoon. I am trying to download a file from an FTP server using WinSCP. But it is not working when the name of the file contains the character ]. I tried to escape the character with backtip but it doesn't work.

Any tip? Thanks
# Configuración de conexión al servidor SFTP
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
    Protocol = [WinSCP.Protocol]::Sftp
    HostName = "xx"
    UserName = "xx"
    Password = "xx"
    GiveUpSecurityAndAcceptAnySshHostKey = $true
}
 
# Carpeta remota y local
$remotePath = "/Xplora px"
$localPath = "C:\Descargas"
 
# Nombre exacto del archivo a descargar
$targetFileName = "Prexi[t.sdat"
 
Write-Host "Descargando: $remoteFilePath -> $localFilePath"
$transferResult = $session.GetFiles($remoteFilePath, $localFilePath, $false)