Created
December 14, 2012 02:52
-
-
Save JGallardo/4282240 to your computer and use it in GitHub Desktop.
Ruby script that can join files.
This file contains 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 characters
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