Topic "Qustion About script of WInscp"

Author Message
justinchenjy@...

Guest


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

Guest


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

Code:
$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!
justinchenjy@...

Guest


prikryl 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:

Code:
$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?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
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.
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