EvilZone
Programming and Scripting => Scripting Languages => : pyte January 03, 2013, 08:36:48 PM
-
HI,
wrote this code with an intention to copy files from a specified directory / file
import os
import shutil
sourcePath = r'G:/Air.doc'
destPath = r'C:\Users\Desktop\test'
shutil.copy(sourcePath, destPath)
this only copies a specified file(in my case Air.doc)
Now ild like to know how ild modify the same to copy everything from a specified drive over a network and also be able to attach the files to an email and send automatically at a scheduled time.
-
Not sure about attaching to emails and whatnot, but to copy all files, do this:
instead of
sourcePath = r'G:/Air.doc'
put
sourcePath = r'G:/*.*'
or better yet, just
sourcePath = "G:\\*.*"
-
great! that works. thanx :)
-
If you want to keep a folder structure you can use batch
@echo off
xcopy "C:\location\folder" "C:\destination\folder" /e
-
.If you want to keep a folder structure you can use batch
@echo off
xcopy "C:\location\folder" "C:\destination\folder" /e
can i inc operate this to my python code?
i got no experience with batch though it looks quite clea
-
.can i inc operate this to my python code?
i got no experience with batch though it looks quite clea
Yes, you can use popen or system in the os module.
As for email, you will need to look up MIME types and how to creation emails in python. There are built-in libs, so go Google.