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:
Sys.time())- format
A format to be applied to the times; set to
NULLto skip formatting- sep
A
charactervector of length 1 to separate the timestamp from the file name
Examples
file1 <- tempfile(fileext = ".txt")
file2 <- tempfile()
add_file_timestamp(file1)
#> /tmp/Rtmp0vvHCh/file1d15438c69cd 2025-10-20 051537.txt
add_file_timestamp(file2)
#> /tmp/Rtmp0vvHCh/file1d157bcc91de 2025-10-20 051537
file.remove(file1, file2)
#> Warning: cannot remove file '/tmp/Rtmp0vvHCh/file1d15438c69cd.txt', reason 'No such file or directory'
#> Warning: cannot remove file '/tmp/Rtmp0vvHCh/file1d157bcc91de', reason 'No such file or directory'
#> [1] FALSE FALSE