O comando "Novo nome" na GUI do WinSCP não pode renomear automaticamente o arquivo enviado para não entrar em conflito com arquivos existentes.
Também não existe essa função no script WinSCP .
Embora você possa codificar isso usando assembly WinSCP .NET , por exemplo, usando PowerShell :
try
{
# Load WinSCP .NET assembly
Add-Type -Path "WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "example.com"
$sessionOptions.UserName = "username"
$sessionOptions.Password = "password"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx..."
$localPath = "c:\local\path\*.txt"
$remotePath = "/remote/path/"
try
{
# Connect
Write-Host "Connecting..."
$session = New-Object WinSCP.Session
$session.SessionLogPath = "session.log"
$session.Open($sessionOptions)
# Upload files
Write-Host "Uploading..."
$localFiles = Get-ChildItem -Path $localPath
foreach ($localFile in $localFiles)
{
$name = $localFile.Name;
Write-Host "Found file $name"
$index = 0;
while ($session.FileExists($remotePath + $name))
{
Write-Host "$name exists already in remote directory"
$index++;
$name = $localFile.Name + " ($index)"
}
Write-Host "Uploading as $name ..."
$session.PutFiles($localFile, $remotePath + $name).Check()
}
Write-Host "Done"
}
finally
{
# Disconnect, clean up
$session.Dispose()
}
exit 0
}
catch [Exception]
{
Write-Host $_.Exception.Message
exit 1
}