Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error downloading file to local subfolder using WinSCP

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

like image 283
Rhodo Avatar asked May 07 '13 14:05

Rhodo


People also ask

How do I download files from WinSCP to local?

First select the remote files or directories you want to download. You can select the files in the remote panel, either in file list or in directory tree (one directory only). Then drag your selection and drop it on local directory. If you are using Commander interface you can drop the files on its local panel.

How do I copy files from one directory to another in WinSCP?

To move remote files, select them in file panel and then go to File(s) > Move to. You can also drag selected files to a different directory in file panel listing or directory tree. You will be then prompted with the dialog, where you can alter a destination directory and specify operation mask.

How do I open a local directory in WinSCP?

Go to View > Go To > Open Directory/Bookmark in the Explorer interface, or Local (Remote) > Go To > Open Directory/Bookmark in the Commander interface, or find the respective icon on a toolbar, or use keyboard shortcut Ctrl+O .

How do I zip a folder in WinSCP?

The script is distributed in WinSCP installer as a WinSCP extension. To use a different archive format than ZIP, you can install 7-Zip, add configure the extension to use it. For opposite functionality, use extension Archive remote files to ZIP archive, download it, and optionally extract it.


1 Answers

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.

like image 111
Martin Prikryl Avatar answered Sep 25 '22 03:09

Martin Prikryl