Created
August 3, 2010 01:23
-
-
Save huacnlee/505670 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux 遍历目录下面所有文件,将文件名转为小写 | |
#!/usr/bin/python | |
# the following script will traverse through all of the files | |
# within the directory where it is placed and replace each | |
# underscore within the filename with a space | |
import os, sys,re | |
print "Auto convert Upper filename to Lower filename" | |
dir = '/home/huacnlee/uploadfiles' | |
print "find files..." | |
for root,dirs,files in os.walk(dir): | |
print root | |
print str(len(files)) + " found." | |
os.rename(root,root.lower()) | |
for f in files: | |
filename = root.lower() + "/" + f | |
if re.search('[A-Z]',filename) != None: | |
print filename | |
newfilename = filename.lower() | |
print "Renaming", f, "to", f.lower(), "..." | |
os.rename(filename, newfilename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment