Code: Alles auswählen
import os
import re
def dir_list2(directory, *args):
fileList = []
content = os.walk(directory, topdown = False)
for root, subFolders, files in content:
for file in fileList:
dirfile = os.path.join(directory, file)
if os.path.isfile(dirfile):
if len(args) == 0:
fileList.append(dirfile)
else:
if os.path.splitext(dirfile)[1][1:] in args:
fileList.append(dirfile)
#Adds Files to fileList
print "##################################################"
print "Old filename:", file
filename = file
remove = re.compile("[^.a-zA-z0-9_]")
output = remove.sub('_', filename)
newfile = directory + "/" + output
os.rename(dirfile, newfile)
print "Corrected filename:", output
#Removes Special Characters
#print "######################################"
return fileList
if __name__ == '__main__':
fileList = dir_list2('/path')
#for f in fileList:
# print f
Danke im voraus
Henry