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
Post a Comment