Advertisement
steve-shambles-2109

187-Rename files to Unix friendly

Oct 23rd, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  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())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement