Created
November 30, 2018 08:54
-
-
Save vigliag/b0621fa01eb0463d5389550bc4a2edbc 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
import os | |
import re | |
if __name__ == "__main__": | |
top = '/tmp/shared' | |
ren = '/tmp/shared2' | |
for dp, dn, fns in os.walk(top, topdown=False): | |
for fn in fns: | |
porig = os.path.join(dp, fn) | |
if "/." in porig: | |
continue | |
p = re.sub(r"[^\w/\.]", "-", porig) | |
p = p.replace("_", "-") | |
p = p.replace("-/", "/") | |
p = re.sub(r"\-+", "-", p) | |
p = p.replace(top, ren) | |
print(p) | |
#os.renames(porig, p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment