[Tutor] Convert my .bat and .vbs to .py

Mike Hansen Mike.Hansen at atmel.com
Thu Feb 15 18:28:20 CET 2007


 

> -----Original Message-----
> From: tutor-bounces at python.org 
> [mailto:tutor-bounces at python.org] On Behalf Of Mark Bystry
> Sent: Thursday, February 15, 2007 10:04 AM
> To: tutor at python.org
> Subject: [Tutor] Convert my .bat and .vbs to .py
> 
> Hello,
> 
> This is my first post. I have just begun to code with python. 
> My goal is to convert about a dozen or 
> so DOS/Windows batch scripts(.bat) and vbscripts(.vbs) that I 
> use on a day-to-day basis to python so 
> that they can be run on either my windows or linux workstations.
> 
> The first things that I want to learn is how to do basic 
> stuff like copying, moving, and deleting 
> files around from folder to folder. I have been in the help 
> section of python (copyfile section) 
> but I do not understand what I am doing wrong.
> 
> 
> Here is my simple DOS batch file...
> 
> ######################################################################
> copy D:\PDF_Holding\*PRODUCTION.pdf Z:\
> copy D:\PDF_Holding\*ILLUSTRATION.pdf 
> H:\MARKETING\ILLUSTRATIONS\PRODUCT
> pause
> 
> del *.pdf
> ######################################################################
> 
> Basically, it copies the "production" and "illustration" pdf 
> files to certain folders than deletes 
> the left over pdf files when done. Yes, I could move them 
> instead of copying them.
> 
> I'm no asking for anyone to write this for me but if someone 
> could lead me i the right direction, I 
> would be grateful.
> 
> Thank-you.
> 
> Mark

Maybe there's a way to use shutil's copytree function with os module's
remove function or shutil's rmtree function? If not, use the glob module
to gather the file names and then walk the results of the glob with a
for loop and use shutil's copyfile function.

Mike


More information about the Tutor mailing list