Topic "I need SFTP to create remote directories via command line"

Author Message
unabletostay

Guest


Hi,

I'm using 5.1.3.0 via command line on a growing number of servers to backup a specific location. I'm using a Windows environmental variable %computername% so minimise customisation of the script per server.

I'm finding that when attempting to transfer to /%computername%/Data that because the /%computername% doesn't exist it fails. This makes sense and from my understanding this is by design. Is there however any switches I can use to change this so it does create the directory?

Script below:

Code:
winscp.com /log=log.txt /script=backupScript.txt


Code:
backupScript.txt

option batch abort
option confirm off
open username:password@server
synchronize remote -delete "E:\Data" "/%computername%/Data"
exit


Thanks in advance for your help. Smile
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24991
Location: Prague, Czechia
Code:
option batch continue
mkdir /%computername%/Data
option batch abort


But you still get an error exit code and error record in the log.

Clean solution would be to use Session.FileExists from WinSCP .NET assembly:
https://winscp.net/eng/docs/library_session_fileexists
_________________
Martin Prikryl
unabletostay

Guest


Thank you kindly Smile
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