How do I rename the extension of an individual file through Ruby? -
i'm trying figure out efficient way of renaming single file's extension. i've looked bunch of methods online, of them seem converting files in bulk, using basic .each blocks. in blocks, noticed fileutils used lot, supposed because directory path given usage imminent. know how bulk method, i'm not sure individual method, w/ along lines of: def convert_file_extension(input_file) ... end
any appreciated!
this statement trick:
def self.rename_file(input_file, output_file) file.rename(input_file, output_file) if !file.exist?(output_file) end thanks @7stud & @ostapische!
Comments
Post a Comment