Created
October 21, 2012 21:44
-
-
Save FiXato/3928616 to your computer and use it in GitHub Desktop.
Icons Renamer
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'fileutils' | |
base_dir = File.join("E:","Filip","Development","icons") | |
suffix = 'fatcow' | |
size = 32 | |
files = Dir.glob(File.join("E:","Filip","Development","icons","fatcow-hosting-icons-3000",'32x32',"*.png")) | |
files.each do |filepath| | |
fn = File.basename(filepath) | |
# md = fn.match(/(.+)_(\d+)(\..+)/) | |
# size = md.captures[1] | |
md = fn.match(/(.+)(\..+)/) | |
ext = md.captures.last | |
dir = File.join(base_dir,'%sx%s' % [size,size]) | |
name = md.captures.first | |
target = File.join(dir,"#{name}_#{suffix}#{ext}") | |
FileUtils.mkpath(dir) | |
FileUtils.cp(filepath,target) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment