Skip to content

Instantly share code, notes, and snippets.

@cavb
Created September 9, 2017 15:54
Show Gist options
  • Save cavb/023ddd129e37d1399d95768ed5ad31ce to your computer and use it in GitHub Desktop.
Save cavb/023ddd129e37d1399d95768ed5ad31ce to your computer and use it in GitHub Desktop.
# Replaces whitespaces with underscore of all files from this location
import os
path = os.getcwd()
filenames = os.listdir(path)
for filename in filenames:
os.rename(os.path.join(path, filename), os.path.join(path, filename.replace(' ', '_')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment