Created
May 10, 2011 08:05
-
-
Save evolve2k/964077 to your computer and use it in GitHub Desktop.
Rename files in a directory into a slug format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class String #:nodoc: | |
| def to_slug | |
| self.gsub(/ /,"_").gsub(/&/,"and").gsub(/\?|\!|\#/,"").downcase | |
| end | |
| end | |
| files = Dir.glob("*") | |
| files.each { |f| File.rename(f, f.to_slug) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment