filesstrings (version 0.3.2)

UnitDirs: Put files with the same unit measurements into directories.

Description

Say you have a number of files with "5min" in their names, number with "10min" in the names, a number with "15min" in their names and so on, and you'd like to put them into directories named "5min", "10min", "15min" and so on. This function does this, but not just for the unit "min", for any unit.

Usage

UnitDirs(unit, pattern = NULL, dir = ".")

Arguments

unit
The unit upon which to base the categorising.
pattern
If set, only files with names matching this pattern will be treated.
dir
In which directory do you want to perform this action (defaults to current)?

Value

Invisibly TRUE if the operation is successful, if not there will be an error.

Details

This function takes the number to be the last number (as defined in NthNumber()) before the first occurrence of the unit name. There is the option to only treat files matching a certain pattern.

Examples

Run this code
setwd(tempdir())
dir.create("UnitDirs_test")
setwd("UnitDirs_test")
files <- c("1litres_1.txt", "1litres_3.txt", "3litres.txt", "5litres_1.txt")
file.create(files)
UnitDirs("litres", "\\.txt")
setwd("..")
RemoveDirs("UnitDirs_test")

Run the code above in your browser using DataLab