It contains nearly the same, thats why I didn't posted one.
- Tibi
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.
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).
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.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