Skip to content

Instantly share code, notes, and snippets.

@b-coimbra
Last active January 23, 2018 02:03
Show Gist options
  • Save b-coimbra/6de86b5511c47430940b7e631b0e805b to your computer and use it in GitHub Desktop.
Save b-coimbra/6de86b5511c47430940b7e631b0e805b to your computer and use it in GitHub Desktop.
Script to rename .png files with their respective dimensions
#!/usr/bin/env ruby
# encoding: UTF-8
Dir['*'].each { |f|
File.rename(f, ((File.binread(f.to_s)[0x10..0x18].unpack('NN')*?x + ' ' + f) if File.extname(f)[/\.png/])) if f != $0
} rescue Errno::ENOENT abort '[!] Run as admin.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment