consolidate {warbleR}R Documentation

Consolidate (sound) files into a single directory

Description

consolidate copies (sound) files scattered in several directories into a single one.

Usage

consolidate(files = NULL, path = NULL, dest.path = NULL, pb = TRUE, file.ext = ".wav$",
parallel = 1, save.csv = TRUE, ...)

Arguments

files

character vector indicating the subset of files that will be consolidated. File names should include the full file path. Optional.

path

Character string containing the directory path where the sound files are located. 'wav.path' set by warbleR_options is ignored. If NULL (default) then the current working directory is used.

dest.path

Character string containing the directory path where the sound files will be saved. If NULL (default) then the current working directory is used.

pb

Logical argument to control progress bar. Default is TRUE.

file.ext

Character string defining the file extension (i.e. format) for the files to be consolidated. Default is '.wav$' ignoring case. Several formats can be used: "\.wav$|\.wac$|\.mp3$|\.flac$".

parallel

Numeric. Controls whether parallel computing is applied. It specifies the number of cores to be used. Default is 1 (i.e. no parallel computing).

save.csv

Logical. Controls whether a data frame containing sound file information is saved in the new directory. Default is TRUE.

...

Additional arguments to be passed to the internal file.copy function for customizing file copying.

Details

This function allows users to put files scattered in several directories into a single one. By default it works on sound files in '.wav' format but can work with other type of files (for instance '.txt' selection files).

Value

All (sound) files are consolidated (copied) to a single directory ("consolidated_files"). The function returns a data frame with each of the files that were copied in a row and the following information:

If csv = TRUE (default) a 'file_names_info.csv' file with the same information as the output data frame is also saved in the consolidated directory.

Author(s)

Marcelo Araya-Salas (marcelo.araya@ucr.ac.cr)

References

Araya-Salas, M., & Smith-Vidaurre, G. (2017). warbleR: An R package to streamline analysis of animal acoustic signals. Methods in Ecology and Evolution, 8(2), 184-191.

See Also

fix_wavs for making sound files readable in R

Examples

{
# save wav file examples
data(list = c("Phae.long1", "Phae.long2", "Phae.long3", "Phae.long4", "lbh_selec_table"))

# create first folder with 2 sound files
dir.create(file.path(tempdir(), "folder1"))
writeWave(Phae.long1, file.path(tempdir(), "folder1", "Phae.long1.wav"))
writeWave(Phae.long2, file.path(tempdir(), "folder1", "Phae.long2.wav"))

# create second folder with 2 sound files
dir.create(file.path(tempdir(), "folder2"))
writeWave(Phae.long3, file.path(tempdir(), "folder2", "Phae.long3.wav"))
writeWave(Phae.long4, file.path(tempdir(), "folder2", "Phae.long4.wav"))

# consolidate in a single folder
# consolidate(path = tempdir(), dest.path = tempdir())

# check this folder
tempdir()
}


[Package warbleR version 1.1.30 Index]