Replace File Extension
replace_file_extension.Rd
This function replaces the file extension of a given filename with a specified new extension. It validates the input to ensure the filename and the new extension are single character strings. Then, it replaces the old extension with the new one and returns the modified filename.
Arguments
- filename
The input filename as a character string.
- new_extension
The new file extension to replace the old one (including the dot, e.g., ".bib").
Examples
if (FALSE) {
# Replace the file extension of a text file with a BibTeX extension
new_filename <- replace_file_extension("example_document.txt", ".bib")
print(new_filename) # "example_document.bib"
}