Moving/Copying files
The first way: use the os-specific function "cp" in linux and "copy" in windows.
The other way: open the sourcefile, read the sourcefile, open the target file, write the sourcefile to the targetfile...
The other way: open the sourcefile, read the sourcefile, open the target file, write the sourcefile to the targetfile...
mfg,
10011110
10011110
Just have a look at the standard module 'shutil', which provides some convenient functions for this. I'm not sure if this is platform-independent.
Good luck
Jörg
Good luck
Jörg
Now what i have is,
in the directory c:\temp , i have 10 txt files
and i want to move them to d:\temp
with shutil i tried
copyfile('c:\temp\*.txt' ,''d:\temp\')
is this valid ?
Excuse my ignorance, i am new at Python
in the directory c:\temp , i have 10 txt files
and i want to move them to d:\temp
with shutil i tried
copyfile('c:\temp\*.txt' ,''d:\temp\')
is this valid ?
Excuse my ignorance, i am new at Python
If you want to use shell patterns you need the module 'glob' too:
This should work, but I didn't test it.
Joerg
Code: Alles auswählen
import shutil, glob
for f in glob.glob(r"c:\ham\*.txt"):
shutil.copy(f, r"d:\ham\")
Joerg