[Tutor] New to Python..Need help

Joel Goldstick joel.goldstick at gmail.com
Thu Sep 4 21:01:50 CEST 2014


On Thu, Sep 4, 2014 at 8:49 AM, Felisha Lawrence
<felisha.lawrence at gmail.com> wrote:
> Hello,
> I have a question regarding strings in python. I have a directory on my
> MacBook Bro of about 13 files. I need to alter the file endings in that
> directory. The files are on the order of
> 'swp.113006004000_KLWX_0.0.5_PPI_v2','swp.113006004000_KLWX_0.0.5_PPI_v3'. I
> need to remove the characters after the 'v' and replace with v20. All of the
> endings of the files are sequential _v2, _v3,_v4, _v5. I need all of these
> characters to be the same (i.e. v20). I would like to know which modules are
> best to use, and how to use loops to alter them. Any help you can provide
> would be great.
>
>
Check out the documentation for os.walk and os.rename.  The first to
collect you filenames, and the second to rename them.

> 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)
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Joel Goldstick
http://joelgoldstick.com


More information about the Tutor mailing list