Remove spaces in file names in a specified directory, replacing them with whatever you want, default nothing.
remove_filename_spaces(dir = ".", pattern = "", replacement = "")
The directory in which to perform the operation.
A regular expression. If specified, only files matching this pattern will be treated.
What do you want to replace the spaces with? This defaults to nothing, another sensible choice would be an underscore.
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.
if (FALSE) {
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")
}