Qustion About script of WInscp

Advertisement

justinchenjy@...
Guest

Qustion About script of WInscp

Dear Support,

i have a question.
i am using script to use winscp upload file to sftp server.
one of script is "option transfer binary"
i want to know, when i using this script, what is the order of the upload?
File name or frie created time?

hope your reply!

thanks

justin

Reply with quote

Advertisement

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

Re: Qustion About script of WInscp

Files are uploaded in the order as they are presented by the operating system.

So generally the order is undefined, though the files are commonly sorted by a name.

Reply with quote

justinchenjy@...
Guest

Re: Qustion About script of WInscp

martin wrote:

Files are uploaded in the order as they are presented by the operating system.

So generally the order is undefined, though the files are commonly sorted by a name.

Hi prikryl,


Thanks for reply.


if i want upload order by file create time, which option i can select?

BR

Justin

Reply with quote

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

Re: Qustion About script of WInscp

There's no such option.
You would have to code it.
E.g. using a PowerShell script using WinSCP .NET assembly.
It should be pretty easy.

You start with these examples:
https://winscp.net/eng/docs/script_upload_most_recent_file
https://winscp.net/eng/docs/script_upload_file_list

And you modify the first like:

$files =
    Get-ChildItem -Path $localPath |
    Sort-Object LastWriteTime -Ascending

foreach ($file in $files)
{
    Write-Host ("Uploading {0} ..." -f $file.Name)
    $session.PutFiles($session.EscapeFileMask($localPath + $file.Name), $remotePath).Check()
}

Not tested!

Reply with quote

justinchenjy@...
Guest

Re: Qustion About script of WInscp

martin wrote:

There's no such option.
You would have to code it.
E.g. using a PowerShell script using WinSCP .NET assembly.
It should be pretty easy.

You start with these examples:
https://winscp.net/eng/docs/script_upload_most_recent_file
https://winscp.net/eng/docs/script_upload_file_list

And you modify the first like:

$files =
    Get-ChildItem -Path $localPath |
    Sort-Object LastWriteTime -Ascending

foreach ($file in $files)
{
    Write-Host ("Uploading {0} ..." -f $file.Name)
    $session.PutFiles($session.EscapeFileMask($localPath + $file.Name), $remotePath).Check()
}

Not tested!

Hi Supporter,

Thanks!
and one more question, when i upload some big zip file.
some time this process will be broken and system will re-upload auto.
in re-upload process, will the destination SFTP server have a broken zip file or not?

Reply with quote

Advertisement

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

Re: Qustion About script of WInscp

justinchenjy@... wrote:

and one more question, when i upload some big zip file.
some time this process will be broken and system will re-upload auto.
in re-upload process, will the destination SFTP server have a broken zip file or not?
WinSCP wouldn't resume the transfer, if the result would not be a valid file. Of course the disconnect is an indication of some problem. So you never can be 100% sure. But there's just a small probability of a problem.

Reply with quote

Advertisement

You can post new topics in this forum