Debian Codegraph @

man/rename_seq.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/paths.R
3 \name{rename_seq}
4 \alias{rename_seq}
5 \title{Rename files with a sequential numeric prefix}
6 \usage{
7 rename_seq(
8 pattern = "^[0-9]+-.+[.]Rmd$",
9 format = "auto",
10 replace = TRUE,
11 start = 1,
12 dry_run = TRUE
13 )
14 }
15 \arguments{
16 \item{pattern}{A regular expression for \code{\link[=list.files]{list.files()}} to obtain
17 the files to be renamed. For example, to rename \code{.jpeg} files, use
18 \code{pattern = "[.]jpeg$"}.}
19
20 \item{format}{The format for the numeric prefix. This is passed to
21 \code{\link[=sprintf]{sprintf()}}. The default format is \code{"\\\%0Nd"} where \code{N = floor(log10(n)) + 1} and \code{n} is the number of files, which means the
22 prefix may be padded with zeros. For example, if there are 150 files to be
23 renamed, the format will be \code{"\\\%03d"} and the prefixes will be
24 \code{001}, \code{002}, ..., \code{150}.}
25
26 \item{replace}{Whether to remove existing numeric prefixes in filenames.}
27
28 \item{start}{The starting number for the prefix (it can start from 0).}
29
30 \item{dry_run}{Whether to not really rename files. To be safe, the default is
31 \code{TRUE}. If you have looked at the new filenames and are sure the new
32 names are what you want, you may rerun \code{rename_seq()} with
33 \code{dry_run = FALSE} to actually rename files.}
34 }
35 \value{
36 A named character vector. The names are original filenames, and the
37 vector itself is the new filenames.
38 }
39 \description{
40 Rename a series of files and add an incremental numeric prefix to the
41 filenames. For example, files \file{a.txt}, \file{b.txt}, and \file{c.txt}
42 can be renamed to \file{1-a.txt}, \file{2-b.txt}, and \file{3-c.txt}.
43 }
44 \examples{
45 xfun::rename_seq()
46 xfun::rename_seq("[.](jpeg|png)$", format = "\%04d")
47 }