[Tutor] simply moving files
msh at blisses.org
Tue May 12 19:51:36 CEST 2009
On monday I posted the below code:
... src = '/home/datasvcs/PIG/cjomeda_exp/'
... dst = '/home/datasvcs/PIG/cjomeda_exp_archive/'
... listOfFiles = os.listdir(src)
... for filez in listOfFiles:
... os.system("mv"+ " " + src + " " + dst)
David Angel replied to my post and I guess I accidentally deleted his response. Today I found his response posted on mail-archive.com and tried some variations. They all failed.
David said, "Just use os.rename() if the dest is a directory, it'll move the file there."
Example: If I use: "os.rename(src, dst)" where I had "os.system("mv"+ " " + src + " " + dst)" no files are coppied.
os.renames happily renames the source directory, but that's not what I want.
Any other suggestions?
I fear you speak upon the rack,
Where men enforced do speak anything.
- William Shakespeare
More information about the Tutor