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

Anonymous wrote:

thanks for your reply
however Transfer to temporary filename is supported with SFTP protocol ?

OK, you are using FTP, right?
Then you would have to do everything programmatically (enumeration of files, finding differences, transfer to temporary file name, rename).
Guest

this is my scripts

try
{
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::ftp
HostName = "XXX"
UserName = "XXX"
Password = "XXX"

}


$session = New-Object WinSCP.Session
try
{
# Will continuously report progress of synchronization
$session.add_FileTransferred( { FileTransferred($_) } )

# Connect
$session.Open($sessionOptions)
#Define the file type to downloaded
$transferoptions= New-Object WinSCP.TransferOptions
$TransferOptions.FileMask = "*.jpg;*.txt"

# Synchronize files

$synchronizationResult = $session.SynchronizeDirectories(
[WinSCP.SynchronizationMode]::local, "d:\downloads\pic\", "/pic/", $false,$false,1,$TransferOptions)

# Throw on any error
$synchronizationResult.Check()
}

finally
{
# Disconnect, clean up
$session.Dispose()
}
}
catch [Exception]
{
Write-Host ("Error: {0}" -f $_.Exception.Message)

}
Guest

thanks for your reply
however Transfer to temporary filename is supported with SFTP protocol ?
ivanyeung

powershell synchronize with changing file extension while downloading.

hi
i want to synchronize the local path from the remote ftp server.
on the remote server,there are jpg files,i get success with the standard synchronize method.
however,how can i changing the file extension from .jpg to let say .txt while downloading and rename it to .jpg after downloaded?