Skip to content

Instantly share code, notes, and snippets.

@FiXato
Created October 21, 2012 21:44
Show Gist options
  • Save FiXato/3928616 to your computer and use it in GitHub Desktop.
Save FiXato/3928616 to your computer and use it in GitHub Desktop.
Icons Renamer
#!/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