Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'things.': 0.05; 'shutil': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'scripting': 0.09; 'terry': 0.09; 'language': 0.14; '"\\\\"': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'script.': 0.17; 'jan': 0.18; 'windows': 0.19; 'module': 0.19; 'import': 0.21; 'linux': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'functions.': 0.27; 'header:X -Complaints-To:1': 0.28; 'print': 0.32; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'received:org': 0.36; 'subject:: ': 0.38; 'files': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'side': 0.61; 'subject:...': 0.63; 'received:fios.verizon.net': 0.84; 'do:': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Opinion on best practice... Date: Tue, 05 Feb 2013 02:56:39 -0500 References: <207d17ce-4bc7-487c-acde-6a7b9f66002b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <207d17ce-4bc7-487c-acde-6a7b9f66002b@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360051187 news.xs4all.nl 6851 [2001:888:2000:d::a6]:56726 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38174 On 2/4/2013 11:14 PM, Anthony Correia wrote: > I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? > > import os > > objdir = ("C:\\temp2") > colDir = os.listdir(objdir) > for f in colDir: > activefile = os.path.join(objdir + "\\" + f) > print ("Removing " + activefile + " from " + objdir) > os.remove(activefile) > > In Powershell I would just do: > > $colDir = gci -path "c:\temp2" > ForEach($file in $colDir) Python comes with a shutil module with multiple copy functions. -- Terry Jan Reedy