scp - recursively copy files by creating required paths in destination directory using python -


i want recursively copy files server location machine preserving directory structure.

server structure

/opt/shared/dir1/dir2/dir3/sample.json   /opt/shared/dir1/dir2/dir3/sample2.json    /opt/shared/dir1/dir2/sample.json   /opt/shared/dir1/dir2/sample2.json 

i want find sample.json starting /opt/shared/dir1 , copy these local machine maintaining structure.

/home/users/a/dir1/dir2/dir3/sample.json
/home/users/a/dir1/dir2/sample.json

i using python2.7

i can use os.walk @ server files but
how copy create directory structure?
how use scp copy machine?

import os import fnmatch top=/opt/shared/dir1 allfiles=[] filepattern="sample.json" path, dirlist, filelist in os.walk(top):         name in fnmatch.filter(filelist,filepattern):           allfiles.append(os.path.join(path,name)) 


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -