Skip to contents

Adds a timestamp to a file

Usage

add_file_timestamp(
  x,
  ts = Sys.time(),
  format = "%Y-%m-%d %H%M%S",
  sep = " "
)

Arguments

x

A vector of files

ts

A single timestamp or vector of timestamps (default: base::Sys.time())

format

A format to be applied to the times; set to NULL to skip formatting

sep

A character vector of length 1 to separate the timestamp from the file name

Value

The full name paths with the appended time stamp

Examples

file1 <- tempfile(fileext = ".txt")
file2 <- tempfile()

add_file_timestamp(file1)
#> /tmp/Rtmp0L4wgL/file1992417eac10 2026-11-27 182358.txt
add_file_timestamp(file2)
#> /tmp/Rtmp0L4wgL/file199259cc4002 2026-11-27 182358