X-Received: by 10.66.66.109 with SMTP id e13mr21490053pat.1.1400661703051; Wed, 21 May 2014 01:41:43 -0700 (PDT) X-Received: by 10.140.38.199 with SMTP id t65mr24849qgt.17.1400661702936; Wed, 21 May 2014 01:41:42 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!c1no12296919igq.0!news-out.google.com!qf4ni5721igc.0!nntp.google.com!c1no12296908igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Wed, 21 May 2014 01:41:42 -0700 (PDT) In-Reply-To: <2122e5a9-198d-4998-bebf-3f19fe110f57@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.98.70.139; posting-account=mz2-UgoAAABhHsO0mzb5w7wo3Dt0FOo5 NNTP-Posting-Host: 194.98.70.139 References: <8ff7483f-cec3-4cc8-bedf-68da09571350@googlegroups.com> <89887b39-3988-45cf-9a26-02f3eeef9f22@googlegroups.com> <934ba77e-6794-4d41-a3f3-ca0e370c4afb@googlegroups.com> <575e4180-b222-4e8f-a378-f39a51c3c085@googlegroups.com> <45b38d71-bf27-4d8e-b912-1093bbb38dcb@googlegroups.com> <2122e5a9-198d-4998-bebf-3f19fe110f57@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <99a414b6-0d02-40ac-9891-e179ff296db8@googlegroups.com> Subject: Re: 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. From: Satish ML Injection-Date: Wed, 21 May 2014 08:41:42 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: csiph.com comp.lang.python:71844 On Wednesday, May 21, 2014 6:59:40 AM UTC+5:30, Rustom Mody wrote: > On Tuesday, May 20, 2014 9:35:10 PM UTC+5:30, Jagadeesh N. Malakannavar w= rote: > Hi Satish, > > Can you please send python part in plain text format= ? Python code here is > > difficult to read. It would be helpful to read ht= tps://wiki.python.org/moin/GoogleGroupsPython#Posting_from_Google_Groups No= te particularly the 2 standard expectations: - Dont top post - Dont use exc= essively long (> 70 chars) lines Hi, Here is the code. xls file looks as follows: a.c C:\Desktop\salingeg\src\code\a.c C:\Desktop\salingeg\dest\code hello.txt C:\Desktop\salingeg\src\txt\hello.txt C:\Desktop\salingeg\dest\tx= t integration.doc C:\Desktop\salingeg\src\doc\integration.doc C:\Desktop\sali= ngeg\dest\doc UG.doc C:\Desktop\salingeg\src\doc\UG.doc C:\Desktop\salingeg\dest\doc Applications.xml C:\Desktop\salingeg\src\xml\Applications.xml C:\Desktop\sa= lingeg\dest\xml Platforms.xml C:\Desktop\salingeg\src\xml\Platforms.xml C:\Desktop\salingeg= \dest\xml avc.alias C:\Desktop\salingeg\src\cnx\alias\avc.alias C:\Desktop\salingeg\d= est\cnx\alias cats.alias C:\Desktop\salingeg\src\cnx\alias\cats.alias C:\Desktop\salingeg= \dest\cnx\alias avc.init C:\Desktop\salingeg\src\cnx\init\avc.init C:\Desktop\salingeg\dest= \cnx\init cats.init C:\Desktop\salingeg\src\cnx\init\cats.init C:\Desktop\salingeg\de= st\cnx\init =09 =09 PYTHON SCRIPT: import xlrd, sys, os, shutil file_location =3D "C:\Users\salingeg\Desktop\input.xls" workbook =3D xlrd.open_workbook(file_location) sheet =3D workbook.sheet_by_index(0) sheet.cell_value(0, 0) for row in range(sheet.nrows): source =3D [] source.append(sheet.cell_value(row, 1)) destination =3D [] destination.append(sheet.cell_value(row, 2)) files =3D [] files.append(sheet.cell_value(row, 0)) for f in files: for s in source: for d in destination: print f print s print d if (os.path.exists("d\\f")): print ('File exists') else: shutil.copy(s, d) =20 I am getting the following error: a.c C:\Desktop\salingeg\src\code\a.c C:\Desktop\salingeg\dest\code Traceback (most recent call last): File "C:\Users\salingeg\Desktop\excel_1.py", line 24, in shutil.copy(s, d) File "C:\Program Files (x86)\python26\lib\shutil.py", line 84, in copy copyfile(src, dst) File "C:\Program Files (x86)\python26\lib\shutil.py", line 50, in copyfil= e with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: u'C:\\Desktop\\salingeg\\src\= \code\\a.c'