Last active
March 30, 2020 17:35
-
-
Save lkhedlund/895af2868317868f0a543ebc0f7543bb to your computer and use it in GitHub Desktop.
Replace commas in directory filenames (Current 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
# Download into directory and run `python rename_files.py` | |
# importing os module | |
import os | |
# Function to rename multiple files | |
def main(): | |
for filename in os.listdir("./"): | |
# Replace commas in filename with nothing | |
newfilename = filename.replace(',', '') | |
os.rename(filename, newfilename) | |
# Driver Code | |
if __name__ == '__main__': | |
# Calling main() function | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment