Question

I use a batch file to get into WinSCP. The .bat reads a script file containing this:

cd /download/.stuff
get file.txt D:\Name\Sub Name\Even Lower 

changes directory fine, finds file fine, but when it comes to placing it in Sub-folder directory on my local computer I get this error

Can't get attributes of file ' D:\Name\Sub Name\Even'.
No such file or directory

I think that the syntax is correct.

Any reason why it's not dropping into that sub folder?

Thanks

Was it helpful?

Solution

As @Rub mentioned, it's the spaces. You need to enclose the paths with spaces into double-quotes. Also, you need to terminate the path with backslash. Otherwise it's going to download the file to file Even Lower in local directory D:\Name\Sub Name. But I assume that you want it to download to D:\Name\Sub Name\Even Lower, keeping the name file.txt.

This is correct syntax:

get file.txt "D:\Name\Sub Name\Even Lower\"

Some references:
https://winscp.net/eng/docs/scripting#syntax
https://winscp.net/eng/docs/scriptcommand_get

The error message you are getting does not make much sense. When trying the same, I'm getting:

Can't get attributes of file 'D:\Name\Sub'
No such file or directory.

That makes sense as your command means: Download three remote files file.txt, D:\Name\Sub and Name\Even to local file Lower in your local current working directory (overwritting one another). So it fails finding remote file D:\Name\Sub.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top