Skip to content

Instantly share code, notes, and snippets.

@JGallardo
Created December 14, 2012 02:52
Show Gist options
  • Save JGallardo/4282240 to your computer and use it in GitHub Desktop.
Save JGallardo/4282240 to your computer and use it in GitHub Desktop.
Ruby script that can join files.
if ARGV.size != 1
puts "Usage: ruby fileJoin.rb <filename.ext>"
puts "Example: ruby fileJoin.rb myfile.txt"
exit
end
file = ARGV[0]
piece = 0
orig_file = "New.#{file}"
if File.exists?("#{file}.rsplit#{piece}")
ofile = File.open(orig_file, "w")
while File.exists?("#{file}.rsplit#{piece}")
puts "Reading File: #{file}.rsplit#{piece}"
ofile << File.open("#{file}.rsplit#{peice},", "r").read.chomp
piece+=1
end
ofile.close
puts "\nSUCESS! File reconstructed."
else
puts "\nCould not find #{file}.rsplit#{piece}."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment