Created
April 21, 2015 15:16
-
-
Save ninjs/75bceb058887d02c2e30 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
def dir_rename | |
dir = Dir.open(__dir__) | |
puts "Renaming folders..." | |
dir.each do |file| | |
next if File.file?(file) | |
if File.directory?(file) | |
base_name = File.basename(file) | |
next if base_name.start_with?('11') | |
next if base_name.start_with?('--') | |
if base_name.include?(" ") | |
no_dash = base_name.gsub('-', ' ') | |
full_name = no_dash.split(/ /)[0..1].join(' ') | |
begin | |
File.rename(file, full_name) | |
rescue | |
print "File #{base_name} is in use and was skipped." | |
end | |
end | |
end | |
end | |
end | |
dir_rename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment