[Tutor] Renaming Files in Directory

Felisha Lawrence felisha.lawrence at gmail.com
Thu Oct 9 01:58:38 CEST 2014


Hello,
I have the following program


 import os

path = '/Users/felishalawrence/testswps/vol1'
for file in os.listdir(path):
        newFile = path+file[:file.rindex("v")]+"v20"

        print newFile

and I want to output the results of the 'newFile' variable into the
directory specified by the 'path' variable. There are current files in this
directory, but I would like tho replace them with different names. Can
anyone point me in the right direction?


Thanks,
Felisha Lawrence


-- 
Felisha Lawrence
Howard University Program for Atmospheric Sciences(HUPAS), Graduate Student

NASA URC/BCCSO Graduate Fellow
NOAA NCAS Graduate Fellow
Graduate Student Association for Atmospheric Sciences(GSAAS), Treasurer
(240)-535-6665 (cell)
felisha.lawrence at gmail.com (email)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141008/9c11308a/attachment.html>


More information about the Tutor mailing list