Skip to content

Instantly share code, notes, and snippets.

@meqif
Created April 2, 2009 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meqif/89319 to your computer and use it in GitHub Desktop.
Save meqif/89319 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# Generates a SFV file from the filename, since anime fansubs usually add the
# CRC32 checksum to the end of the filename. This allows one to check the
# checksums with a common SFV checker.
#
# (C)opyright 2009 Ricardo Martins <ricardo at scarybox dot net>
# Licensed under the MIT/X11 License. See LICENSE file for license details.
require 'date'
def getCRC32(filename)
filename.split(' ').last.split('.').first.split('')[1..-2].join('')
end
def header
now = DateTime.now
"; Generated by generate_sfv v0.1 on #{now.year}-#{now.month}-#{now.day} \
at #{now.hour}:#{now.min}:#{now.sec}"
end
def main
puts header
files = Dir.entries(".").sort - [".", ".."]
files.each do |filename|
puts filename + " " + getCRC32(filename)
end
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment