1

Our bank just changed the way in which upload and download files to them. Previously we could log in to a secured website, choose directory, and upload/download manually. Everything now has to be done through SFTP, using FileZilla or similar program.

I want to automate SFTP upload process by using WinSCP.

I realize I will need to use the put command line to upload. The file I'm wanting to upload is generated every day and the file name is exactly the same, but the folder being uploaded from changes. The directory structure is as such:

C:\Finance\FY 2021\YYYYMMDD\file.txt

My question is what would the upload command line look like to upload this file on a daily basis. This upload will always take place the same day, so the folder name will always be the current date in the above format.

Can these commands be contained within and run from a batch file rather than creating a batch file that merely points to a scripted txt file to run? Thanks for your help!


A follow-up question for handling of the FY YYYY part part:
Use WinSCP to upload from a folder with a fiscal year in its name to an SFTP server

0

1 Answer 1

1

WinSCP has %TIMESTAMP% syntax which you can use to refer to the folder with today's timestamp in its name.

And yes, you can specify WinSCP commands directly in the batch file using the /command parameter:

winscp.com /ini=nul /command ^
    "open sftp://username:password@ftp.example.com/ -hostkey=""...""" ^
    "put ""C:\Finance\FY 2021\%%TIMESTAMP#yyyymmdd%%\file.txt"" ""/remote/path/""" ^
    "exit"
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.