Created
July 8, 2023 14:44
-
-
Save PaperNick/817168972280d0bc45d627e4ec8b848c to your computer and use it in GitHub Desktop.
Revisions
-
PaperNick created this gist
Jul 8, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ from pathlib import Path special_chars = ('<', '>', ':', '"', '/', '\\', '|', '?', '*', '/') def replace_all(text, items): for i in items: text = text.replace(i, '') return text print('WARNING: Scaning large directories trees may take a lot of time.') for file in Path('.').glob('**/*'): if any(map(lambda char: char in file.name, special_chars)): new_name = replace_all(file.name, special_chars) print(f'Old name: {file}') print(f'New name: {file.with_name(new_name)}') print() file.rename(file.with_name(new_name))