Topic "Create local folder if it does not exist"

Author Message
Nucleus
[View user's profile]

Joined: 2010-06-29
Posts: 1
I am using WinSCP v4.2.7 build 758 in a batch file to backup my ftp server locally. I also use other variables in the batch file, to put each backup of WinSCP in a different local folder.

My problem is that if the local folder does not exist, WinSCP stops. Is there a way to tell WinSCP to create the local folder if it does not exist?

This is the batch file I use

Code:
winscp.exe /log=C:\logs\log.txt /console /command "option batch on" "open username:password@host.com" "synchronize local C:\localfolder /home1/username/public_html/remotefolder" "close" "exit"
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
No, WinSCP won't create target directory. You can create it on your own using mkdir command in the batch file that runs WinSCP (if there any).
_________________
Martin Prikryl
Guest




Hi Martin,

Why does Winscp create the missing folder structure when wild cards are used, but not when the full path is given. For example this works:

/folder1/folder2/*.* C:\folder1\folder2\

(only C:\folder1\folder2\ exists, but the file /folder1/folder2/folder3/folder4/file1.txt is successfully copied to C:\folder1\folder2\folder3\folder4\file.txt, hence winscp creates folder3\folder4 in order to copy the file.

However, this does not work and gives error: Can't create file
/folder1/folder2/folder3/folder4/file1.txt C:\folder1\folder2\folder3\folder4\file.txt
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
The root target path must exist.
In the first example, the root is C:\folder1\folder2\
In the second example, the root is C:\folder1\folder2\folder3\folder4\
That's common behavior, most command-line tools behave this way.
_________________
Martin Prikryl
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