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

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to