R: Remove spaces in file names

remove_filename_spaces {filesstrings} | R Documentation

## Remove spaces in file names

### Description

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

### Usage

    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

    ## 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)

[Package filesstrings version 2.5.0 Index]