Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. library("DescTools")
  2.  
  3. mainDir <- "~"
  4. readExtension <- function()
  5. {
  6. extFileName <- readline(prompt="Enter an extension file name: ")
  7. extFiledir <- file.path(mainDir, extFileName)
  8. if(file.exists(extFiledir) == FALSE) {
  9. dir.create(extFiledir)
  10. } else {
  11. unlink(extFiledir, recursive = TRUE)
  12. }
  13. fileList <- list.files(path = mainDir, pattern = extFileName, recursive = FALSE)
  14. index <- 1
  15. while(index<=length(fileList)) {
  16. strPosIndex <- StrPos(pattern = extFileName, fileList[index])
  17. if(is.na(strPosIndex) == FALSE) {
  18. file.copy(file.path(mainDir, fileList[index]), extFiledir)
  19. }
  20. index <- index + 1
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement