Copying files from sub folders under source directories into sub folders with same names as source directory sub folders in destination directories without overwriting already existing files of same name.

Satish ML satishmlwizpro at gmail.com
Mon May 19 04:08:36 EDT 2014


On Monday, May 19, 2014 12:31:05 PM UTC+5:30, Chris Angelico wrote:
> On Mon, May 19, 2014 at 4:53 PM, <satishmlwizpro at gmail.com> wrote: > Could you kindly help? Sure. Either start writing code and then post when you have problems, or investigate some shell commands (xcopy in Windows, cp in Linux, maybe scp) that can probably do the whole job. Or pay someone to do the job for you. ChrisA

Consider xls file contains source and destination directory paths.
import xlrd, sys, subprocess
file_location = "C:\Users\User1\Desktop\input.xls"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(0)
sheet.cell_value(0, 0)
for row in range(sheet.nrows):
  
            values = []
   
            values.append(sheet.cell_value(row, 1))
            
  
            destination = []
            destination.append(sheet.cell_value(row, 2))
            
            
            for s in values:
                        
                        for d in destination:
                               What next after this? 
shutil.copy(src, dest) doesn't work because it overwrites dest files.



More information about the Python-list mailing list