Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'read.': 0.03; 'linux,': 0.07; 'subject:same': 0.07; 'subject:files': 0.09; 'subject:into': 0.09; 'sys,': 0.09; 'windows,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(source': 0.16; 'command,': 0.16; 'dest': 0.16; 'directory)': 0.16; 'format?': 0.16; 'help?': 0.16; 'investigate': 0.16; 'path.': 0.16; 'subject: \n ': 0.16; 'subject:already': 0.16; 'subject:sub': 0.16; 'subject:under': 0.16; 'sure.': 0.16; 'values:': 0.16; 'wrote:': 0.18; 'help.': 0.21; 'import': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header :User-Agent:1': 0.23; 'directory.': 0.24; 'exists': 0.24; 'mon,': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'source': 0.25; 'skip:" 30': 0.26; 'skip:v 30': 0.26; 'post': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'chris': 0.29; 'code': 0.31; 'file': 0.32; 'lists': 0.32; 'probably': 0.32; 'option': 0.32; 'text': 0.33; 'url:python': 0.33; '(i.e.': 0.33; 'monday,': 0.33; 'plain': 0.33; 'maybe': 0.34; 'subject:from': 0.34; 'could': 0.34; 'subject:with': 0.35; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'two': 0.37; 'url:library': 0.38; 'files': 0.38; 'pm,': 0.38; 'that,': 0.38; 'does': 0.39; 'either': 0.39; 'how': 0.40; 'read': 0.60; 'commands': 0.60; 'manually': 0.60; 'kindly': 0.61; 'you.': 0.62; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'header:Reply-To:1': 0.67; '20,': 0.68; 'message- id:@localhost.localdomain': 0.74; 'reply-to:addr:gmail.com': 0.80; '2014,': 0.84; 'subject:source': 0.84; 'url:path': 0.84; 'destination': 0.91; 'sheet': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:reply-to:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version:content-type; bh=Vq2JyrH6gdL6jLOM/inbTG/RDnWgfqDl4NjLp1p8snY=; b=sXYFDXfDf7dB4/s/s6snR7gVyW/8FazVA0IxC6UNf7WSD39YeS3/3YGqd2DsIH1lcg 3CPJ34Xq1cqNuGWu8pYmbK+4IJGfZgScDw3JN63PfuutwcqdZcGaXl6AThzjtS4wDGEA 3u1HWnqSxbBeIeGqRz1F9gIgNMw06F0LoL3/Sng+/v98w/Cl8by/QQJcVFQhYZHgX7VT j2are4FYf5Uupq1szcMnGyHiyObuSqmPUBOEeMgV6qvgSskktb1rAA7ppXOLEhqFm6Yd Bf6ZxYdsGnt1xf+/ZlgoQH0ua8buDBh4iI+3h8HVn6AJLLdAMQ82niBdJ8vQzZiU2Sfn fSGw== X-Received: by 10.68.133.229 with SMTP id pf5mr52411835pbb.115.1400601936736; Tue, 20 May 2014 09:05:36 -0700 (PDT) Date: Tue, 20 May 2014 21:35:10 +0530 (IST) From: Jagadeesh Malakannavar X-X-Sender: njagadeesh@localhost.localdomain To: Satish ML 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. In-Reply-To: <45b38d71-bf27-4d8e-b912-1093bbb38dcb@googlegroups.com> 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> User-Agent: Alpine 2.11 (LRH 23 2013-08-11) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-427932426-1400601935=:22217" X-Mailman-Approved-At: Tue, 20 May 2014 18:20:43 +0200 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Jagadeesh Malakannavar List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1400602844 news.xs4all.nl 2890 [2001:888:2000:d::a6]:56965 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71811 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-427932426-1400601935=:22217 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Transfer-Encoding: QUOTED-PRINTABLE Hi Satish, Can you please send python part in plain text format? Python code here is= =20 difficult to read. Thanks On Tue, 20 May 2014, Satish ML wrote: | On Tuesday, May 20, 2014 5:54:47 PM UTC+5:30, Satish ML wrote: | > On Tuesday, May 20, 2014 5:51:19 PM UTC+5:30, Satish ML wrote: > On Tue= sday, May 20, 2014 11:27:01 AM UTC+5:30, Rustom Mody wrote: > On Monday, Ma= y 19, 2014 2:32:36 PM UTC+5:30, Satish ML wrote: > On Monday, May 19, 2014 = 12:31:05 PM UTC+5:30, Chris Angelico wrote: > > On Mon, May 19, 2014 at 4:5= 3 PM, wrote: > Could you kindly help? Sure. Either start writing code and t= hen 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 > Hi ChrisAngelico, > Consider th= at source and destination directories are given in a .xls(excel) file. > Th= is is the code > import xlrd, sys, subprocess > file_location =3D "C:\Users= \salingeg\Desktop\input.xls" > workbook =3D xlrd.open_workbook(file_locatio= n) > sheet =3D workbook.sheet_by_index(0) > sheet.cell_value(0, 0) > for ro= w in range(sheet.nrows): > values =3D [] > values.append(sheet.cell_value(r= ow, 1)) > destination =3D [] > dest | ination.append(sheet.cell_value(row, 2)) > for s in values: > for d in d= estination: > If I am using cp or xcopy command, it will copy all files fro= m s to d. > shutil.copy(s, d) can't be used here because it overwrites file= s in d. Kindly help. have u tried using https://docs.python.org/2/library/o= s.path.html#os.path.exists ? I have tried it. But how does it help? We won'= t be able to make out whether source file is present in destination directo= ry. If we can do that, like if (source file exists in destination directory= ) print "exists" continue else shutil.copy(s, d) |=20 | Here we don't have the option of manually giving the file path. It has to= be read from .xls file (i.e. from the two lists in code) |=20 --8323328-427932426-1400601935=:22217--