-
Notifications
You must be signed in to change notification settings - Fork 25
/
Rakefile
32 lines (29 loc) · 835 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'fileutils'
ARTBOARDS = {
"01" => "twitter",
"02" => "facebook",
"03" => "linkedin",
"04" => "google",
"05" => "openid",
"06" => "yahoo",
"07" => "aol",
"08" => "myspace",
"09" => "github",
"10" => "basecamp",
"11" => "campfire",
"12" => "presently"
}
desc "Rename automatically exported files to their proper service names."
task :rename do
FileList["**/*"].each do |file|
ext = File.extname(file)
dir = File.dirname(file)
if file.match /.*-[0-9]{2}\..(?:png|jpg)/i
size, index = File.basename(file).split('.')[0].split('-')
`mv #{file} #{dir}/#{ARTBOARDS[index]}_#{size}#{ext}`
puts "+ Moved #{file} to #{dir}/#{ARTBOARDS[index]}_#{size}#{ext}"
elsif file.match /authbuttons-([0-9]{2})\.eps/i
`mv #{file} #{dir}/#{ARTBOARDS[$1]}.eps`
end
end
end