Utilities for managing file names.
filename provides a S3 class to represent file names, which is
inter-convertible with character.
This function creates a filename object with a file path, tags,
extensions, date stamp or date-time stamp.
filename(x, path = NULL, tag = NULL, ext = NULL, date = NULL, time = NULL, subdir = TRUE)
x |
file name stem |
path |
path to the file |
tag |
tags for the file name |
ext |
file extension |
date |
date stamp ( |
time |
time stamp ( |
subdir |
whether to append a date/time stamped subdirectory to path |
Either construct a filename object with the filename
constructor or convert an existing file name from character to
filename using as.filename.
Then, manage the tags and extensions of the filename object with
insert.
Use tag to quickly add or replace a tag on a file name (as a
character or filename and coerce into a character.
The date and time parameters can be specified as
character vectors or date/time objects. If time
is given as a POSIXct, it will override date.
If these parameters are both NULL, automated date and time stamping
may be done and is controlled by getOption("filenamer.timestamp").
If this option is NULL, 0, or less,
no date or time stamping will be done;
if it is 1, only date stamping will be done;
if it is 2 or greater, date-time stamping will be done (default).
Set date or time to NA to suppress date or
time stamping for a particular filename.
Stamps are shown in ISO 8601 date format (
(
platforms and are thus omitted; hyphens are omitted from date-time stamps
for brevity.
By default, a date stamped subdirectory is appended to the filepath.
To disable this behaviour, set subdir to FALSE or disable
path stamping globally by options(filenamer.path.timestamp = 0).
This option is similar to filenamer.timestamp above.
a filename object
# file name is date-time stamped and put in subdirectory by default
fn <- filename("data", tag="qc", ext="txt")
print(as.character(fn))
# disable date-time stamping and subdirectory insertion
fn2 <- filename("data", tag="qc", date=NA, time=NA, subdir=FALSE)
print(as.character(fn2))
# creating a new file name from an existing one yields a new time stamp
fn3 <- filename(fn)
print(as.character(fn3))Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.