Chris
Chris

Reputation: 677

Upload file to specific folder on SFTP site with WinSCP?

I have a batch file with the following code to upload csv file(s) to an SFTP site from a folder where the file name contains '3630' using WinSCP. This works and dumps our files onto the site, but ideally I need to dump them into a specific folder called 'uploads' on the SFTP site. Is this achievable and how am I able to do this by changing the below code?

##Transfer Setting

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Scheduled_Tasks\Bartec\bartec_error.log" /ini=nul ^
  /command ^
    "open sftp://user:pass@mysftpsite/ -hostkey=""myhostkey""" ^
    "lcd D:\GGP\GGPLive\DEPT\NLPG\HubUpdate" ^
    "cd /" ^
    "put *3630_*csv" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%

Upvotes: 1

Views: 1472

Answers (1)

Chris
Chris

Reputation: 677

Just found out it was fairly straight forward, by including an additional argument for the 'put' statement to the target path on the FTP site!

"put *3630_*csv mytargetpath/" ^

Upvotes: 1

Related Questions