Create local folder if it does not exist

Advertisement

Nucleus
Joined:
Posts:
1

Create local folder if it does not exist

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

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"

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Create local folder if it does not exist

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).

Reply with quote

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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
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.

Reply with quote

Advertisement

You can post new topics in this forum