remove_filename_spaces: Remove spaces in file names

Description Usage Arguments Value Examples

Description

Remove spaces in file names in a specified directory, replacing them with whatever you want, default nothing.

Usage

1
remove_filename_spaces(dir = ".", pattern = "", replacement = "")

Arguments

dir

The directory in which to perform the operation.

pattern

A regular expression. If specified, only files matching this pattern will be treated.

replacement

What do you want to replace the spaces with? This defaults to nothing, another sensible choice would be an underscore.

Value

A logical vector indicating which operation succeeded for each of the files attempted. Using a missing value for a file or path name will always be regarded as a failure.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
dir.create("RemoveFileNameSpaces_test")
setwd("RemoveFileNameSpaces_test")
files <- c("1litres 1.txt", "1litres 30.txt", "3litres 5.txt")
file.create(files)
remove_filename_spaces()
list.files()
setwd("..")
dir.remove("RemoveFileNameSpaces_test")

## End(Not run)

Example output

Loading required package: stringr
[1] TRUE TRUE TRUE
3 files required renaming and this was done successfully.
[1] "1litres1.txt"  "1litres30.txt" "3litres5.txt" 
1 directory deleted. 0 failed to delete.

filesstrings documentation built on April 18, 2021, 9:12 a.m.