remap_filename {neurobase}R Documentation

Build Filename (usually for images)

Description

This is a simple function that helps with the case where you want to construct a filename (usually for an image) with the same base of the filename, the same directory (default), but things added to the front or end of that base filename, with the same extension.

Usage

remap_filename(x, sub_dir = NULL, prefix = "", suffix = "")

Arguments

x

input filename/character vector

sub_dir

sub-directory for the new filename. If NULL, then the directory is the the same directory as x

prefix

string to put in front of base of filename

suffix

string to put at the end of base of filename

Value

Character vector

Examples

fname = file.path("/path/to/file", "original.nii.gz")
remap_filename(fname, prefix = "preproc_", "_with_gz")
fname = "original.nii"
remap_filename(fname, prefix = "note_", "_has_directory")
remap_filename(c(fname, "other.nii.gz"), prefix = "note_", "_has_directory")

[Package neurobase version 1.32.4 Index]