rename_bundles: Batch rename bundles

View source: R/reindeeR_database.R

rename_bundlesR Documentation

Batch rename bundles

Description

This function simplifies renaming of bundles.

Usage

rename_bundles(emuDBhandle, bundles)

rename_bundles(emuDBhandle, bundles)

Arguments

emuDBhandle

An emuR database handle

bundles

data.frame like object with the columns

  • session: name of sessions containing bundle

  • name: name of bundle

  • name_new: new name given to bundle

It is worth noting that session and name are the columns returned by list_bundles.

from

A tibble or data.frame with columns "session" and "name", identifying the bundle to rename. The usual procedure is to first invoke list_bundles and then filter out the bundles the user wants to rename.

to

A vector of strings containing new names of the bundles in from. The vector has to be of the same length as the number of rows in from.

simulate

Boolean; Should the bundle renaming just be simulated, or actually performed?

Details

The user it expected to supply a data frame and tibble with "session" and "name" columns, and a vector of new bundle names with the length as the number of rows in the from data.frame. The function will then rename all bundle directories and all files in the bundle directories to the new name one by one.

Bundle renaming is a sensitive process and many things can go wrong. Therefore the function will by default simulate the file renaming and return a summary of the plan for the user to review. The user may then enter the same arguments again and set simylate=TRUE to actually perform the renaming.

If the database is part of a git repository, the changes will be committed and pushed

Value

Either the updated bundle listing, or a tibble showing the file renaming plan.

See Also

emuR::rename_bundles

Examples


## Not run: 
library(dplyr)
reindeer:::create_ae_db() -> emuDBhandle
r <- list_bundles(emuDBhandle) %>%
  dplyr::mutate(to=toupper(name)) %>%
  dplyr::mutate(to=stringr::str_replace(to,"([A-Z]+)([0-9]+)","\\1-\\2")) %>%
  dplyr::mutate(to=tolower(to))

 print(rename_bundles(emuDBhandle,r[1:2,c("session","name")],r[1:2,"to"],simulate=TRUE))

## End(Not run)


humlab-speech/reindeer documentation built on May 21, 2023, 4:43 p.m.