copying a file in python
Hai friends
I have a small problem with my code...
I want to copy an existing file (its a model MS Excel file) to a new file & name it with the current date...
First I tried to create the model Excel file, but when I opened it, it had only one sheet inside it, so I tried to copy the existing file, but I couldnt find any bright ideas... can anyone show me a way?
import sys
import win32com.client
fileVM = open('e:/disk/vm.xls','a')
fileVM.close()
The above code creates the file with a single Excel Sheet inside it. But my model file has a lot of info, so I wud prefer to copy & then rename the existing file...
xav.vijay
Junior Poster in Training
55 posts since Aug 2005
Reputation Points: 10
Solved Threads: 6
You may want to use shutil.copy(sourcefile, destinationfile), it gives copy the current date, shutil.copy2(sourcefile, destinationfile) gives the date of the file you copy.
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
Thanks guys , its working fine with windows as well...
xav.vijay
Junior Poster in Training
55 posts since Aug 2005
Reputation Points: 10
Solved Threads: 6