Learn R Programming

TheOpenAIR (version 0.1.0)

replace_file_extension: Replace File Extension

Description

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.

Usage

replace_file_extension(filename, new_extension)

Value

A character string representing the filename with the replaced file extension.

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").

Author

Ulrich Matter umatter@protonmail.com

Examples

Run this code
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"
}

Run the code above in your browser using DataLab