Skip to content

Instantly share code, notes, and snippets.

@lkhedlund
Last active March 30, 2020 17:35
Show Gist options
  • Save lkhedlund/895af2868317868f0a543ebc0f7543bb to your computer and use it in GitHub Desktop.
Save lkhedlund/895af2868317868f0a543ebc0f7543bb to your computer and use it in GitHub Desktop.
Replace commas in directory filenames (Current folder)
# 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