Skip to content

Instantly share code, notes, and snippets.

@dangayle
Last active February 1, 2016 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangayle/5855580 to your computer and use it in GitHub Desktop.
Save dangayle/5855580 to your computer and use it in GitHub Desktop.
Easy python batch file rename one-liner
"""
In the terminal, go to the directory of the files you want to rename
Open yer python CLI, import os, then one-liner. I guess technically 2-liner
"""
import os
[os.rename(f, f.replace('_','-')) for f in os.listdir('.')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment