Created
March 8, 2015 21:18
-
-
Save iamaziz/e24745f804f7e42a155d to your computer and use it in GitHub Desktop.
Change file names in a directory and its sub-directories.
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
import os | |
for dpath, dnames, fnames in os.walk('/path/to/dir'): | |
for f in fnames: | |
os.chdir(dpath) | |
if f.endswith('.pdf'): | |
os.rename(f, f.replace(' ', '-')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for example:
Before
After