Skip to content

Instantly share code, notes, and snippets.

View nicholastjohnson's full-sized avatar

Nicholas Johnson nicholastjohnson

View GitHub Profile
@nicholastjohnson
nicholastjohnson / renameFilesRecursively.py
Last active August 29, 2015 14:04
Recursively remove or replace unwanted characters from filenames in a directory using Python
import os
paths = (os.path.join(root, filename)
for root, _, filenames in os.walk('C:\FolderName')
for filename in filenames)
for path in paths:
# the '#' in the example below will be replaced by the '-' in the filenames in the directory
newname = path.replace('#', '-')
if newname != path: