Advertisement
Guest User

Untitled

a guest
Nov 6th, 2009
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. # -*- coding: cp1252 -*-
  2. import os
  3.  
  4. #file extension that will be added to the end
  5. desiredExtension = ".jpg"
  6.  
  7. #make list of contents of current directory
  8. dirList = os.listdir('')
  9.  
  10. #bring up each filename at a time to rename
  11. for thisFile in dirList:
  12.     if thisFile.endswith(".py") == False and thisFile.endswith(desiredExtension) == False:
  13.  
  14.         (baseName, oldExtension) = os.path.splitext(thisFile)
  15.         os.rename(thisFile, baseName+oldExtension+desiredExtension)
  16.         print(thisFile+" renamed to: "+baseName+oldExtension+desiredExtension)
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement