createFilename {utilitiesR}R Documentation

create a file path based off a given format.

Description

create a file path based off a given format.

Usage

  createFilename(format, fPath = format, base = "",
    overwrite = FALSE)

Arguments

format

A file format optionally containing the following tokens, which will be replaced from the "base" and "fPath" arguments.

item%dthe parent directory of the file in fPath item%Ddirname(fPath) item%ethe extension of the file in fPath (default "tif") item%fthe file name of the file in fPath item%Bthe "base" parameter supplied in the arguments.

fPath

A filepath to grab "%d", "%D", etc from.

base

what to be used as "%B" in "format".

overwrite

boolean, default FALSE, whether to return a filename that doesn't exist in the file system by appending numbers to the end (filename_1, filename_2, ...)

Value

a file name with all the tokens substituted in.

See Also

Other file: dir.browse, file.browse, getExtension, getFilename, getUniqueFilename, makeIfNotExists

Examples

createFilename('%B/%d/%f_new.%e',fPath='/path/to/file.txt',
                base='/new/root/dir')
 # returns '/new/root/dir/to/file_new.txt'
createFilename('%D/%f_smaller.jpg',fPath='~/pictures/img.jpg')
 # returns '~/pictures/img_smaller.jpg'

[Package utilitiesR version 1.7 Index]