Get remote path and file into local relative path

Advertisement

gcb-toronto
Joined:
Posts:
3

Get remote path and file into local relative path

Hi all,

If my script is running from

C:\temp

I want to get remote file

/root/test.txt

into

C:\temp\root\text.txt

without also getting empty directories from under the remote directory.

How to do this? I have experimented with both get and synchronize and filemasks. I have gotten close, but not exactly what I want.

I was able able to do this under Linux using rsync and I am trying to do the equivalent under Windows.

gb

Reply with quote

Advertisement

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

Re: Get remote path and file into local relative path

Use get /* and exclude everything you do not want to transfer using -filemask=.

Reply with quote

gcb-toronto
Joined:
Posts:
3

Re: Get remote path and file into local relative path

martin wrote:

Use get /* and exclude everything you do not want to transfer using -filemask=.

I am transferring a fixed set of files that are in various locations on the disk of a Linux computer. There are possibly hundreds of files that would need to be excluded. The point is to be able to specifically name the files that I want from the remote device. I don't think that excluding the files I do not want would be practical. Does WinSCP offer any better solutions?

Reply with quote

gcb-toronto
Joined:
Posts:
3

Re: Get remote path and file into local relative path

martin wrote:

Use get /* and exclude everything you do not want to transfer using -filemask=.

prikryl, thanks for pointing me in the right direction.

This is what I came up with:

winscp.exe /console /command "option confirm off" "open sftp://root:password@192.168.0.145" "get /root/MYFOLDER/test.txt" "close" "exit"

xcopy "test.txt" ".\root\MYFOLDER\" /Y

Reply with quote

Advertisement

You can post new topics in this forum