Last active
August 6, 2019 15:21
-
-
Save mprostock/a8f8246ac65e3210b01af0588ed83fd8 to your computer and use it in GitHub Desktop.
quick script to rename all files in a folder
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
""" | |
very quick and dirty batch renamer - needed for downloaded files | |
""" | |
import sys | |
from pathlib import Path | |
if len(sys.argv)<2: | |
print("usage: renamer.py FOLDER") | |
print("argument 'FOLDER' missing.") | |
sys.exit(1) | |
folder = sys.argv[1] | |
folder = Path(folder) | |
try: | |
for p in folder.iterdir(): | |
newname = p.name.replace("'","") | |
# newname = newname.replace(","," -") | |
# print(p.name, " - ", newname) | |
p.rename(folder/newname) | |
except Exception as e: | |
print(repr(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment