Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library("DescTools")
- mainDir <- "~"
- readExtension <- function()
- {
- extFileName <- readline(prompt="Enter an extension file name: ")
- extFiledir <- file.path(mainDir, extFileName)
- if(file.exists(extFiledir) == FALSE) {
- dir.create(extFiledir)
- } else {
- unlink(extFiledir, recursive = TRUE)
- }
- fileList <- list.files(path = mainDir, pattern = extFileName, recursive = FALSE)
- index <- 1
- while(index<=length(fileList)) {
- strPosIndex <- StrPos(pattern = extFileName, fileList[index])
- if(is.na(strPosIndex) == FALSE) {
- file.copy(file.path(mainDir, fileList[index]), extFiledir)
- }
- index <- index + 1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement