Last active
July 26, 2018 14:55
-
-
Save Cvetomird91/c4e57bd667e79f2dc47656b38b213495 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python2.4 | |
import os | |
import string | |
path = "/var/spool/asterisk/monitor/" | |
def make_safe_filename(file): | |
safechars = string.letters + string.digits + "-_." | |
try: | |
return filter(lambda c: c in safechars, file) | |
except: | |
return "" | |
pass | |
for root, dirs, files in os.walk(path): | |
for name in files: | |
checkname = make_safe_filename(name) | |
if name != checkname: | |
os.rename(root+'/'+name, root+"/"+checkname) | |
print name, "has been renamed to ", checkname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment