# rename files in directory replace string by another
import os
#r at the beginning of the path so the filename starting with a number sont bien reconnu - raw string literals
renamePath = r"O:\_WORK\PERSO\__SCRIPTS\01_MAYA\_SHELF_custom\shelf_geo_icons"
renamePath = renamePath.replace('\\','/')
# loop and rename
if (renamePath != '') :
for filename in os.listdir(renamePath):
if (len(filename.split('.'))==2): # check if file is not a folder (if it contains an extension)
print filename
newName = filename.replace("ttt","") # replace
os.rename(os.path.join(renamePath, filename), os.path.join(renamePath, newName))