Help with recursive mgets

Advertisement

FlatlanderByTheLake
Joined:
Posts:
4
Location:
Chicago

Help with recursive mgets

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:

/usr/web/config/
[no files in this directory, only subdirectories]
/usr/web/config/abc
myfile.xml
/usr/web/config/def
myfile.xml
myfile.xml.20101113 [don't want this file]
/usr/web/config/ghi
myfile.xml

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!

Reply with quote

Advertisement

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

Re: Help with recursive mgets

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.

Reply with quote

Advertisement

You can post new topics in this forum