Uploading Files Created or Changed Since the Last Upload

Advertisement

aksarben
Joined:
Posts:
72

Uploading Files Created or Changed Since the Last Upload

I see WinSCP has an option to transfer files created/changed since a specified date/time, or length of time.

Can you add the ability for WinSCP to remember the last upload of files with a specified location/mask to a server, then transfer all files with the same location/mask created or changed since that last upload?

Reply with quote

Advertisement

aksarben
Joined:
Posts:
72

Uploading Files Created or Changed Since the Last Upload

I looked at the scripts at https://winscp.net/eng/docs/faq_script_modified_files#last_timestamp. I’m not a PowerShell expert, but unless I’m mistaken, they download server files changed since the last transfer. But we need the opposite action: We have to upload new/changed files from the local machine to the Web server.

Am I missing something?

Just noticed another issue: I need to transfer by SFTP, and I don’t see where the script is specifying the protocol. How do I set the protocol?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Uploading Files Created or Changed Since the Last Upload

I know that you want to "upload". But the principle is still the same.

The code does not set protocol anywhere, as it shows only the transfer part of the code. There are also different pieces of codes for different approaches to the problem. You didn't tell us what approach did you decide to take.

If you plan to use the PowerShell, see:
https://winscp.net/eng/docs/library_powershell#example

Reply with quote

aksarben
Joined:
Posts:
72

Proposed Upload Design

My current plan is to call WinSCP from a PowerShell script, if possible. My design would be to first build set of files to upload. The files will usually be in many different folders. On a typical day, the set would contain 50–100 files. On very rare occasions, it could contain over 15,000 files (e.g., when I’m initializing the Web site on a new server). Questions:
  1. Based on my reading, it seems I have to call Session.PutFileToDirectory once for each file in the set. Is this correct? I’d much prefer to call WinSCP just once, passing it the entire set of files to upload. Is this possible? (I could have the file set include both local/remote names/paths and sizes if needed.)

  2. If I can pass the entire file set to WinSCP in one call, will WinSCP open a window to show progress (files/bytes transferred, time remaining, etc.)?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Proposed Upload Design

  1. WinSCP .NET assembly does not have an API for passing list of files (from different sources) to transfer. What is the problem with calling Session.PutFileToDirectory once for each file?
  2. WinSCP .NET assembly is does not have any UI. It's purely functional library. If you need UI, you need to implement it. Use Session.FileTransferProgress event:
    https://winscp.net/eng/docs/library_session_filetransferprogress#csharp

Reply with quote

aksarben

Rationale for Passing Multiple Files at Once

Re your note "What is the problem with calling Session.PutFileToDirectory once for each file?"

If WinSCP knew all files being uploaded, it could display transfer progress during a scripted session the same way it already does in the GUI. With large file sets, this is an extremely useful feature.

Reply with quote

Advertisement

You can post new topics in this forum