Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, sys
- def change_file_ext(cur_dir, old_ext, new_ext, sub_dirs=False):
- if sub_dirs:
- for root, dirs, files in os.walk(cur_dir):
- for filename in files:
- file_ext = os.path.splitext(filename)[1]
- if old_ext == file_ext:
- oldname = os.path.join(root, filename)
- newname = oldname.replace(old_ext, new_ext)
- os.rename(oldname, newname)
- else:
- files = os.listdir(cur_dir)
- for filename in files:
- file_ext = os.path.splitext(filename)[1]
- if old_ext == file_ext:
- newfile = filename.replace(old_ext, new_ext)
- os.rename(filename, newfile)
- path = "-YOUR FILE PATH-"
- # print os.listdir(path)
- old_ext = ".SDIR"
- new_ext = ".wav"
- change_file_ext(path, old_ext, new_ext, True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement