file backup in windows

Tim Golden Tim.Golden at viacom-outdoor.co.uk
Wed Nov 22 11:02:14 CET 2006


| " c:\documents and settings\060577\Local Settings\Application
| Data\Microsoft\Outlook "
| where 060577 represents username. I want my script to 
| identigy the user
| logged in and go to the resp outlook folder or should be able to read
| outlook store directory path from registry and the copy the files to
| the desired path.
| 
| ---------------------------------------------------
| how can i make the following code work, I have probelm with filepath
| declaration.
| ---------------------------------------------------
| import os, shutil
| filepath = ' C:\\Documents and Settings\\060577\\Local
| Settings\\Application Data\\Microsoft\\Outlook\\* '
| backup = ' D:\\temp\\outlook '
| os.system ("xcopy /s %s %s" % (filepath, backup))
| -----------------------------------------

I suggest you let the system work out most of the
filepath for you. Things like Application Data are
determined by the Windows Shell as they can change
according to Windows version / roaming profile settings
and so on. The following code snippet shows how to
get the Local Application Data folder. It assumes
you have installed the pywin32 extensions from 
http://pywin32.sf.net

<code>
import os, sys
from win32com.shell import shell, shellcon

local_app_data = shell.SHGetSpecialFolderPath (0,
shellcon.CSIDL_LOCAL_APPDATA)
outlook_path = os.path.join (local_app_data, "Microsoft", "Outlook")

print outlook_path

</code)

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list