SHARE
TWEET

187-Rename files to Unix friendly

steve-shambles-2109 Oct 23rd, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2. Python code snippets vol 38:
  3. 187-Rename files to Unix friendly
  4. stevepython.wordpress.com
  5.  
  6. requirements: None
  7.  
  8. (1) Changes spaces to hyphens
  9. (2) Makes lowercase (not a Unix requirement, just looks better ;)
  10.  
  11. source:
  12. https://gist.github.com/igniteflow/1226919
  13. """
  14. import os
  15.  
  16. path = os.getcwd()
  17. filenames = os.listdir(path)
  18.  
  19. for filename in filenames:
  20.     os.rename(filename, filename.replace(" ", "-").lower())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top