filename_extension: filename_extension

Description Usage Arguments Examples

View source: R/filename_extension.R

Description

Iterates through the provided list of files (alphabetically). If a filename has part length length_with_extension (as defined by strsplit using "_"), it is assigned as having an extension/appendix. This function takes the identified extension/appendix part of the filename and appends it to following filenames identified as missing an extension/appendix. Designed for triplicate files in which first file of each group is comprehensively labelled and the others are not, but should work with any number of replicates, provided the filepath contains them in the correct order.

Usage

1
2
filename_extension(filepath = ".", length_with_extension = a,
  length_noextension = b, verbose = TRUE)

Arguments

filepath

Path to files. Defaults to current directory.

length_with_extension

Number of parts to the basename of a file WITH an extension after splitting by "_". Defaults to a.

length_noextension

Number of parts to the basename of a file WITHOUT an extension after splitting by "_". Defaults to b.

verbose

Logical. Should it print descriptions of any changes?

Examples

1
2
3
4
folder <- "FCS_trimmed"
a <- length( unlist(strsplit(basename(list.files(folder)[1]), "_")) )
b <- length( unlist(strsplit(basename(list.files(folder)[2]), "_")) )
filename_extension(filepath = folder, length_with_extension = a, length_noextension = b)

ec363/filenamer documentation built on March 22, 2020, 2:16 a.m.