Skip to contents

[Maturing]

normalize_names() normalizes file and directory names to make them machine-readable.

This function uses dir_ls() to list files/directories to rename, along with make_machine_readable() to rename files.

Usage

normalize_names(
  path = clipr::read_clip(),
  regex = "^README|^OFL.txt$|^DESCRIPTION|^Google README.txt$",
  invert = TRUE,
  ...
)

Arguments

path

(Optional) A character string indicating the directory path. Defaults to clipboard content.

regex

(Optional) A character string with a regular expression to filter files/directories to rename (Default: "^README|^OFL.txt$|^DESCRIPTION|^Google README.txt$").

invert

(Optional) A logical flag indicating if the regular expression in regex should be negated (Default: TRUE).

...

(Optional) Additional arguments to be passed to dir_ls() while listing files/directories to rename.

Value

An invisible NULL. This function is used for its side effect.

Examples

dir <- tempfile("")
dir.create(dir) |> invisible()

file <- tempfile("Test - Test-", tmpdir = dir)
file.create(file) |> invisible()

normalize_names(dir)

list.files(dir)
#> [1] "test-test-1cbf4a3ee4"
#> [1] "test-test-***" # Expected