Created
April 10, 2010 15:28
-
-
Save edulan/362070 to your computer and use it in GitHub Desktop.
This file contains 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
# Make balanced image directories to improve file system search | |
# | |
# Example: | |
# | |
# make_balanced_dirs(2, 4) | |
# ac3294f2b0174ee1.jpg -> ac329/4f2b/ac3294f2b0174ee1.jpg | |
# | |
def make_balanced_dirs levels, length | |
Dir.glob("*.jpg").collect do |f| | |
f.split('.')[0].gsub(/[a-f0-9]{lenght}/) { |m| File.join(m,'') }[0..(levels*length)+1].concat(f) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment