File Splitting
File Splitting
fileSplit.rb
A cool use of Ruby scripting is to split a large file into several smaller, symmetric files. I wrote this script for a friend who was having trouble sending files into and out of his corporate network since the network administrators wouldn't allow files over a certain size to be transferred—presumably for bandwidth reasons. This script worked like a charm.
The Code
if ARGV.size != 2 puts "Usage: ruby fileSplit.rb <filename.ext> <size_of_pieces_in_bytes>" puts "Example: ruby fileSplit.rb myfile.txt 10" exit end filename = ARGV[0] size_of_split = ARGV[1] if File.exists?(filename) file = File.open(filename, ...
Get Wicked Cool Ruby Scripts now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.