import os
def change_multi_file_ext(cur_dir, uzanti, new_ext, sub_dirs=False):
if sub_dirs:
for root, dirs, files in os.walk(cur_dir):
for dosya in files:
file_ext = os.path.splitext(dosya)[1]
for ext in uzanti:
if ext == file_ext:
oldname = os.path.join(root, dosya)
newname = oldname.replace(ext, new_ext)
os.rename(oldname, newname)
else:
files = os.listdir(cur_dir)
for dosya in files:
file_ext = os.path.splitext(dosya)[1]
for ext in uzanti:
if ext == file_ext:
newfile = dosya.replace(ext, new_ext)
os.rename(dosya, newfile) multi uzanitdegistirme
0
●780
- 26-08-2012, 20:40:00