Topic "powershell synchronize with changing file extension while downloading."

Author Message
ivanyeung

Guest


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?
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26331
Location: Prague, Czechia
You can enable a transfer to temporary file name for all files by:
transferOptions.ResumeSupport.State = TransferResumeSupportState.On

https://winscp.net/eng/docs/resume#automatic
https://winscp.net/eng/docs/library_transferresumesupport
Guest




thanks for your reply
however Transfer to temporary filename is supported with SFTP protocol ?
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)

}
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26331
Location: Prague, Czechia
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).
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License