Error downloading file to local subfolder using WinSCP
Asked Answered
I

1

5

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

Indrawn answered 7/5, 2013 at 14:12 Comment(2)
It's probably the spaces, but seems odd it's getting past the first space but not the second. Try putting the whole "D:\..Lower" path in quotes? Try using the space-free short-names for those folders (try dir /X to find them)?Gangrene
Thank you for your response. I tried putting in " " and computer treated it like a file. And when I take away spaces to call the folder "EVENLOWER", computer saves "EVENLOWER" as a file in D:\Name\Sub NameIndrawn
I
7

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.

Intracranial answered 7/5, 2013 at 14:46 Comment(1)
Martin- You're a WinSCP Superstar! I have seen your work on other sites. I made those changes and it worked. Děkuji!Indrawn

© 2022 - 2024 — McMap. All rights reserved.