Created
March 9, 2020 14:49
-
-
Save landge/76b2d2d219a5ebd074647ba57ca09364 to your computer and use it in GitHub Desktop.
Rename files in current and subdirectories!
This file contains 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 pathlib | |
def main(): | |
path = pathlib.Path.cwd() | |
for i in path.glob('**/*'): | |
if ' ' in i.name: | |
print(i,i.name) | |
new_name = i.parent / i.name.replace(' ','_') | |
i.rename(new_name) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment