SFTP - Windows Script to Automate Synchronize Remote to Local Directory using WinSCP
Why Stack Overflow recommends it
Stack Overflow users link it as a worked example when answering or asking about automating WinSCP synchronization from a batch file.
Recommended by 1 people across 1 different months, 2018 to 2020.
What it is
A short screen demo showing how to write a WinSCP script and batch file that logs into a remote SFTP server and synchronizes a remote directory down to a local folder. It links to the script, the batch file, the portable WinSCP download and the WinSCP scripting docs. The video is from the CodeCowboyOrg channel.
What people said
Recommends BoffinBrain · 2018-01 · Stack Overflow · on “Sync Linux directory with Windows network path”
I'd recommend you use WinSCP for this task. When using it as a GUI it's a great tool, but crucially, it can also be automated with ease. Here is a formal guide on how automation works [LINK] and here is a tutorial video [this video] showing how it works in practice with a batch file. You basically want to copy what the guy in the video did, by making a script to log into your remote server and perform a local synchronization. Any other options, such as choosing to mirror, and how to compare existing files, can also be adjusted by looking at the docs.
Cites Pablo prez · 2018-03 · Stack Overflow · on “Executing WinSCP command in batch file”
I am new to batch and trying to execute a script I wrote, essentially I want to go to a remote server copy the files there and transfer it to a folder in my local directory. I am executing the bactch file but nothing is being copied any suggestions would be great. This is my script open sftp://site:@ftp.site.net -hostkey="server finger print" synchronize local C:\Users\localdirectory\Desktop\test2 /Home/folderA/NewFiles exit I am positive all the information is correct because that's how I login with WinSCP. I got this script from [this video]
Cites emalcolmb · 2019-03 · Stack Overflow · on “WinSCP SSH error Unknown command 'ssh-rsa'”
Context: I have CSV files I'm outputting from SQL Server through BCP. I'm trying to securely transfer the files to a remote SFTP folder using WinSCP. Details: When I execute the batch file below through powershell I raise an error 'Unknown command 'ssh-rsa' with the log file showing an exit code = 1 which is failure. Here is what my synchronization file looks like... option batch abort option confirm off open sftp://username:password@sftp.redacted.com -hostkey="ssh-rsa 2048 redacted=ssh-rsa 2048 redacted" synchronize remote D:\redactedDaily_Reports\redacted_Catalog_New_Item /upload/redacted_catalog exit and & my batch file... winscp.com /script=SyncTo_redacted_catalog.txt /log=D:\redacted_Da
Cites Lyra Orwell · 2020-02 · Stack Overflow · on “Is their a way to synchronise a directory on a raspberry pi to a laptop using WinSCP”
I want to be able to synchronize a directory between my Windows laptop and raspberry pi using WinSCP. By "synchronize" I mean if a file is created in the directory by my raspberry pi, it is automatically placed in predefined directory on my laptop. I have already set up a WinSCP connection between these two devices. I was following along using this tutorial [this video] however I reliazed that this was for an FTP server and I also could not save the .bat file or code file into the appropriate directory as it has it has an administrator lock, so I assume that the method is only for FTB servers. Edit I have given myself permissions to save the code files in the appropriate places, however I now rec