Last active
August 29, 2015 14:22
-
-
Save mhayes/066ea78643ebcd4d2ef0 to your computer and use it in GitHub Desktop.
Revisions
-
mhayes revised this gist
Jun 9, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ require "fileutils" names = %w{EXAMPLE_ONE EXAMPLE_TWO} sizes = %w{160x600-4} expanded_sizes = sizes.map do |s| new_sizes = [] size = s.split("-") -
mhayes created this gist
Jun 9, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # quickstart Let's assume you have OS X screenshots named like `Screen Shot 2015-06-09 at 9.39.56 AM.png`. You can use this script to rename them like so: ```bash mark:screens mark$ ruby renamer.rb move ./Screen Shot 2015-06-09 at 9.39.56 AM.png to EXAMPLE_ONE_160x600_1.png move ./Screen Shot 2015-06-09 at 9.39.57 AM.png to EXAMPLE_ONE_160x600_2.png move ./Screen Shot 2015-06-09 at 9.39.58 AM.png to EXAMPLE_ONE_160x600_3.png move ./Screen Shot 2015-06-09 at 9.40.00 AM.png to EXAMPLE_ONE_160x600_4.png move ./Screen Shot 2015-06-09 at 9.40.30 AM.png to EXAMPLE_TWO_160x600_1.png move ./Screen Shot 2015-06-09 at 9.40.31 AM.png to EXAMPLE_TWO_160x600_2.png move ./Screen Shot 2015-06-09 at 9.40.32 AM.png to EXAMPLE_TWO_160x600_3.png move ./Screen Shot 2015-06-09 at 9.40.34 AM.png to EXAMPLE_TWO_160x600_4.png ``` 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ require "fileutils" names = %w{EXAMPLE_ONE EXAMPLE_TWO} sizes = %w{160x600-3 300x250-4 300x600-4 728x90-4} expanded_sizes = sizes.map do |s| new_sizes = [] size = s.split("-") dims = size[0] variations = size[1].to_i variations.times do |i| new_sizes << "#{dims}_#{i+1}" end new_sizes end expanded_sizes.flatten! sizes = [] names.each do |name| sizes << expanded_sizes.map {|size| "#{name}_#{size}"} end sizes.flatten! files = Dir.glob("./Screen*").sort_by {|pth| File.mtime(pth)} raise Exception unless sizes.length == files.length files.each_with_index do |path, idx| puts "move #{path} to #{sizes[idx]}.png" FileUtils.mv path, "#{sizes[idx]}.png" end