[Tutor] Changing filenames

MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV MICHAEL.W.WILSON@CUSTOMS.TREAS.GOV
Mon, 10 Apr 2000 17:04:55 -0400


--955401009@customs.treas.gov
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Description: "cc:Mail Note Part"

     I'm not sure that I know what you want, but here's a go at it
     
     >>> import re
     >>> file = "myfile.doc"
     >>> matchstr = re.compile(r"(\.\w+)$")
     >>> file = matchstr.sub(r".this\1", file)
     >>> print file
     myfile.this.doc
     
     (Is this what you wanted?)
     
______________________________ Reply Separator _________________________________
Subject: [Tutor] Changing filenames 
Author:  <johnc@greatentertaining.com> at smtplink
Date:    4/10/00 1:24 PM


I'd like to change all the filenames in a directory.  They have a standard 
naming convention, but the important stuff is being used as a file type 
extension.  Does anyone know of a way to append the existing extension to 
the end of the filename and then switch all the extensions to ".this"?
-- John C.


--955401009@customs.treas.gov
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Description: "cc:Mail Note Part"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=790242120-10042000>I'd like to change all the filenames in a 
directory.&nbsp; They have a standard naming convention, but the important stuff 
is being used as a file type extension.&nbsp; Does anyone know of a way to 
append the existing extension to the end of the filename and then switch all the 
extensions to ".this"?</SPAN></DIV>
<DIV><SPAN class=790242120-10042000>-- John C.</SPAN></DIV></BODY></HTML>

--955401009@customs.treas.gov--