createFilename {utilitiesR} | R Documentation |
create a file path based off a given format.
createFilename(format, fPath = format, base = "", overwrite = FALSE)
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, ...) |
a file name with all the tokens substituted in.
Other file: dir.browse
,
file.browse
, getExtension
,
getFilename
,
getUniqueFilename
,
makeIfNotExists
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'