Topic "Help with recursive mgets"

Author Message
[View user's profile]

Joined: 2011-02-28
Posts: 4
Location: Chicago
My eyes and fingers are bleeding from all the reading and experimenting I've been doing trying to finish up my script. I am an experienced script writer, and have already written a couple with WinSCP. But I have saved the toughest for last, and I am struggling.

Here is the directory/file structure on the Unix box. I am trying to GET the files called "myfile.xml". There can be files similar, like "myfile.xml.20100228", but I don't want any files like that. ONLY myfile.xml. Here is my file/directory structure:

[no files in this directory, only subdirectories]
myfile.xml.20101113 [don't want this file]

My code results in WinSCP not finding any files in /usr/web/config/ then it quits without recursing through the subdirectories.

Here is my code:

WinSCP.exe MyServer /log=C:\MyScript.log /ini=C:\Admin\WinSCP.ini /console /command "option batch continue" "option confirm off" "get /usr/web/config/myfile.xml; /usr/web/config/*/myfile.xml C:\data\MyServer\" "close" "exit"

On the destination C: drive, if my myfile.xml is found in /usr/web/config/abc, then I would like WinSCP to CREATE that directory (if it doesn't already exist) on the C: drive under C:\data\MyServer, and pull down the myfile.xml and place it in the "abc" directory. Then continue on to the next directory "def", and so on....

Please help!
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24755
Location: Prague, Czechia
Something like following script should do:
option include */;myfile.xml
get /usr/web/config/* C:\data\MyServer\
Only problem is that this will recreate complete directory structure. Even for directories that does not have any myfile.xml in them.
Martin Prikryl
[View user's profile]

Joined: 2011-02-28
Posts: 4
Location: Chicago

Fantastic! That code worked like a charm! We have a saying in America, "You da' man!"

Thank you very much for your help.


You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License