Skip to content

Instantly share code, notes, and snippets.

@jgera
Forked from seanh/formatFilename.py
Created April 13, 2015 16:30
Show Gist options
  • Select an option

  • Save jgera/ecb072e7f131d73887be to your computer and use it in GitHub Desktop.

Select an option

Save jgera/ecb072e7f131d73887be to your computer and use it in GitHub Desktop.
def validfilename(s):
import string
valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
filename = ''.join(c for c in s if c in valid_chars)
filename = filename.replace(' ','_') # I don't like spaces in filenames.
return filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment