The get command fails if destination directory does not exist

Advertisement

alrisk
Guest

The get command fails if destination directory does not exist

Hello.

The download via get command fails if destination directory (in my case on Windows) does not exist yet.
If I create destination directory by hand then download works just fine.
How can I make it work?

------------- DownloadWholeDirectoryScript.txt -------------
open sftp://someUser:somePassword;@someHost -hostKey="ssh-rsa 2048 x:x:x:x:x:x:x:x:x:x:x:x:x:x:x:x"
get /foo/bar/* C:\someDirectory\
exit

------------- Console lauched as administrator -------------
cd C:\Program Files (x86)\WinSCP
C:\Program Files (x86)\WinSCP> winscp.com /ini=nul /script=C:\DownloadWholeDirectoryScript.txt
  Searching for host...
  Connecting to host...
  Authenticating...
  Using username "someUser".
  Authenticating with pre-entered password.
  Authenticated.
  Starting the session...
  Session started.
  Active session: [1] someUser@someHost
  Can't create file 'C:\someDirectory\someFile.txt'.
  System Error.  Code: 3.
  The system cannot find the specified path
  (A)bort, (R)etry, (S)kip, Ski(p) all: Abort
C:\Program Files (x86)\WinSCP>
[/b]

Reply with quote

Advertisement

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

Re: The get command fails if destination directory does not exist

Yes, the destination directory have to exists. That's it.
You can, of course, use mkdir Windows command from a wrapping batch file, to create the directory, before starting WinSCP script.

Reply with quote

Advertisement

You can post new topics in this forum