-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilesystem_functions_base.R
More file actions
39 lines (34 loc) · 1.69 KB
/
filesystem_functions_base.R
File metadata and controls
39 lines (34 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# # renaming utility
#
# setwd("~/../Downloads/Economics/")
#
# # save files to be renamed
# html_chms <- list.files(".", recursive = TRUE,
# pattern = "*.html",
# ignore.case = TRUE,
# include.dirs = TRUE,
# full.names = TRUE)
#
# # get the names for using as names
# chm_only <- gsub(pattern = ".html$", replacement = "", x = html_chms)
#
# # rename
# file.rename(from = html_chms, to = chm_only)
# file extension search
# to prevent recursed directories from being listed use "include.dirs = FALSE"
table(gsub(pattern = ".*\\.", replacement = "", x = list.files("E:/Movies and Shows/", recursive = TRUE,
pattern = "",
ignore.case = TRUE,
include.dirs = FALSE)))
# # if no subdirectories exist "include.dirs" has no effect.
# gsub(pattern = ".*\\.", replacement = "", x = list.files("./Popular Economics/", recursive = TRUE,
# pattern = "",
# ignore.case = TRUE,
# include.dirs = TRUE))
# To unnest desired files to a destination
orig_files_list <- list.files("C:/Users/Acer/Downloads/BTPRT Trance Pack (17-02-2018) [EDM RG]/",
recursive = T, pattern = "*.mp3", full.names = TRUE)
replacement_names <- stringr::str_replace(orig_files_list, ".*/", "")
dest_files_list <- paste("C:/Users/Acer/Downloads/BTPRT Trance Pack (17-02-2018) [EDM RG]/",
replacement_names, sep = "")
file.rename(orig_files_list[1:20], to = dest_files_list[1:20])