filesstrings (version 0.4.0)

RemoveFileNameSpaces: Remove spaces in file names

Description

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

Usage

RemoveFileNameSpaces(dir = ".", pattern = "", replace.with = "")

Arguments

dir

The directory in which to perform the operation.

pattern

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

replace.with

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

Run this code
setwd(tempdir())
dir.create("RemoveFileNameSpaces_test")
setwd("RemoveFileNameSpaces_test")
files <- c("1litres 1.txt", "1litres 30.txt", "3litres 5.txt")
file.create(files)
RemoveFileNameSpaces()
list.files()
setwd("..")
RemoveDirs("RemoveFileNameSpaces_test")

Run the code above in your browser using DataCamp Workspace