当前位置:网站首页>list. files: List the Files in a Directory/Folder
list. files: List the Files in a Directory/Folder
2022-07-05 07:14:00 【RS&Hydrology】
Reprint :https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/list.files
1.list.files Function function
Save the file name in the folder to the list , It is often used to import files in batches . That is, this function can generate the character vector of the specified directory file or directory name .
2.list.files Usage method
list.files(path = ".", pattern = NULL, all.files = FALSE,
full.names = FALSE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
Parameters :
- path: Enter the file path ;
- pattern: An optional regular expression . Only file names that match regular expressions will be returned ( That is, match the file name , Select the desired file , Default is all file names , For example, you want to select all formats as ‘.txt’ The file of ,pattern="*.txt$"), Indicates that the output is in .txt Final document , Be sure to add $ Symbol , Otherwise, only the file name will be selected txt The file of ).
- all.files: Determine whether to return all files , The default value is no ;
- full.names: Determine the return path + file name , The default value is no ( That is, only the file name is returned );
- recursive: Whether to list the files in subfolders , The default value is no ;
- ignore.case: Whether matching file names ignore case , Default no , That is, case is not ignored .
It can also be used list.dirs Get directory list :
dir(path = ".", pattern = NULL, all.files = FALSE,
full.names = FALSE, recursive = FALSE,
ignore.case = FALSE, include.dirs = FALSE, no.. = FALSE)
list.dirs(path = ".", full.names = TRUE, recursive = TRUE)
3. Example
#1. Get the working directory:
getwd()
#2. Setup the working directory:
setwd("C:/Documents and Settings/Folder name")
#3.list files in a specific folder
list.files (path = "C:/Folder/Subfolder1/Subfolder2")
#4. Extract all files in the format ‘.txt’ file
list.files(path = "C:/Folder/",pattern = ".txt$")
边栏推荐
- [framework] multi learner
- Logical structure and physical structure
- Mipi interface, DVP interface and CSI interface of camera
- 一文揭开,测试外包公司的真实情况
- Application of MATLAB in Linear Algebra (4): similar matrix and quadratic form
- Do you choose pandas or SQL for the top 1 of data analysis in your mind?
- DelayQueue延迟队列的使用和场景
- [solved] there is something wrong with the image
- ROS2——ROS2对比ROS1(二)
- What is soda?
猜你喜欢
Brief description of inux camera (Mipi interface)
Ros2 - first acquaintance with ros2 (I)
Import CV2 prompt importerror: libgl so. 1: Cannot open shared object file: no such file or directory
[untitled]
postmessage通信
目标检测系列——Faster R-CNN原理详解
SD_CMD_RECEIVE_SHIFT_REGISTER
ROS2——初识ROS2(一)
The problem of configuring opencv in qt5.13.2 is solved in detail
SD_ CMD_ RECEIVE_ SHIFT_ REGISTER
随机推荐
Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
SD_CMD_SEND_SHIFT_REGISTER
Three body goal management notes
Unity UGUI不同的UI面板或者UI之间如何进行坐标匹配和变换
Spinningup drawing curve
Database SQL practice 3. Find the current salary details of the current leaders of each department and their corresponding department number Dept_ no
Import CV2 prompt importerror: libgl so. 1: Cannot open shared object file: no such file or directory
Application of MATLAB in Linear Algebra (4): similar matrix and quadratic form
Brief description of inux camera (Mipi interface)
Qu'est - ce que l'hydroxyde de sodium?
Special training of C language array
[node] differences among NPM, yarn and pnpm
ORACLE CREATE SEQUENCE,ALTER SEQUENCE,DROP SEQUENCE
【Node】npm、yarn、pnpm 区别
SOC_ SD_ CMD_ FSM
postmessage通信
What does soda ash do?
Database SQL practice 4. Find the last of employees in all assigned departments_ Name and first_ name
ROS2——功能包(六)
The differences and connections among cookies, sessions, JWT, and tokens