Error Listing Directories starting with numbers

Advertisement

Tibi
Joined:
Posts:
5

Error Listing Directories starting with numbers

Hey there,

I have combined two scripts form the documentation from here, the problem ist. I am getting a Error everytime I want to Fetch Files/Folders starting with numbers.
Exact Error: "Exception calling Check with 0 arguments: Error listing directory ... Could not retrieve directory listing" and this only happens, if the folders, I want to download starts with numbers.

Btw it's a FTPES

try
{
   $sessionUrl = "ftp://dadsa:dasd@Sdad1.syx:123/"
   $remotePath = "/test/"
   $localPath = "E:\test"
   $lastTimestamp = $Null
   $timestampFile = "E:\timestamp.txt"
    # WINSCP DLL
    $assemblyPath = if ($env:WINSCP_PATH) { $env:WINSCP_PATH } else { $PSScriptRoot }
    Add-Type -Path (Join-Path $assemblyPath "WinSCPnet.dll")
 
    # FTP Session
    $sessionOptions = New-Object WinSCP.SessionOptions
    $sessionOptions.ParseUrl($sessionUrl)
   
 
    $session = New-Object WinSCP.Session
   $sessionOptions.FtpMode = [WinSCP.FtpMode]::passive
   $session.Open($sessionOptions)
    
    try
    {
   if (Test-Path $timestampFile)
   {
      $lastTimestamp = [DateTime]::ParseExact((Get-Content $timestampFile), 'O', $Null)
   }
   else
   {
      $lastTimestamp = $Null
   }

    $transferOptions = New-Object WinSCP.TransferOptions
 
    if ($lastTimestamp -ne $Null) 
    {
        Write-Host "Downloading files modified after $lastTimestamp..."
        $transferOptions.FileMask = ("*>" + $lastTimestamp.ToString("yyyy-MM-dd HH:mm:ss"))
    }
    else
    {
        Write-Host "Downloading all files..."
    }
 
    $transferResult = $session.GetFiles($remotePath, $localPath, $False, $transferOptions)
    $transferResult.Check()
 
    # Find the latest downloaded file
    $latestTransfer =
        $transferResult.Transfers |
        Sort-Object -Property @{ Expression = { (Get-Item $_.Destination).LastWriteTime } } `
                    -Descending |
        Select-Object -First 1
 
    if ($latestTransfer -eq $Null)
    {
        Write-Host "No files found."
    }
    else
    {
        $lastTimestamp = (Get-Item $latestTransfer.Destination).LastWriteTime
        Write-Host (
            "Downloaded $($transferResult.Transfers.Count) files, " +
            "latest being $($latestTransfer.FileName) with timestamp $lastTimestamp.")
    }
 
    Write-Host "Waiting..."
    Start-Sleep -Seconds 5
   Set-Content -Path $timestampFile -Value $lastTimestamp.ToString("O")
   }
    finally
    {
        # Disconnect, clean up
        $session.Dispose()
    }
 
    $result = 0
}
catch
{
    Write-Host "Error: $($_.Exception.Message)"
    $result = 1
}
 
# Pause if -pause switch was used
if ($pause)
{
    Write-Host "Press any key to exit..."
    [System.Console]::ReadKey() | Out-Null
}
 
exit $result

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Error Listing Directories starting with numbers

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Tibi
Joined:
Posts:
5

The log file

I added the log file as attachment and trimmed, as far as I could.

Btw: The files are definitely available on the server
  • log.txt (8.58 KB, Private file)

Reply with quote

martin
Site Admin
martin avatar

Re: Error Listing Directories starting with numbers

Are you sure it's about the numbers? Can you download other any other subfolders from the test folder? Isn't it that you cannot download any subfolders at all? It's possible that your server cannot handle a command like CWD /XXXXX/10.this.is.a.test-hello-abc (i.e. changing to a folder two levels deep in one step).

Reply with quote

Tibi

Problem

Hmm, I tested other directories as well.. I guess, thats not the numbers, I tested a other remote folder which contains folders that also starts with numbers and they're just working fine. Somehow a few doesn't work. Downloading folders manually works fine.

CWD is supported

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Problem

Tibi wrote:

Hmm, I tested other directories as well.. I guess, thats not the numbers, I tested a other remote folder which contains folders that also starts with numbers and they're just working fine. Somehow a few doesn't work. Downloading folders manually works fine.
So please post a log file for both these scenarios as well (other folders what work fine and the manual download).

Reply with quote

Tibi
Joined:
Posts:
5

I attached a logfile for a working directory, that I downloaded with the script. Which contains 2 folders, that where downloaded.
  • log.log (67.42 KB, Private file)

Reply with quote

Advertisement

You can post new topics in this forum