How to copy all the files in certain Directory and recreate the directory structure dynamically using python -


i want move files of type existing directory structure new dynamic directory structure.for e.g: if file is

c://users//desktop//635289512-251.txt 

i need place file in

c://users//desktop//635_users//2895_access//635289512-251.txt 

should copy each , everyfile , paste them in directory or can zip them , unzip them dynamically? using below code create directory. please me if there better way of doing this.

thank you help.

src = "folder1/folder2/file1" dst = "folder3"+src dstfolder = os.path.dirname(dst) if not os.path.exists(dstfolder): os.makedirs(dstfolder) shutil.copy(src,dst) 

use shutil.copytree copy entire directory new location.

import shutil  src = "folder1/folder2/file1" dst = "folder3"+src dstfolder = os.path.dirname(dst) shutil.copytree(src,dstfolder) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -