当前位置:网站首页>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$")
边栏推荐
- Ros2 - ros2 vs. ros1 (II)
- About vscode, "code unreachable" will be displayed when calling sendline series functions with pwntools“
- Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
- Skywalking all
- 数学分析_笔记_第8章:重积分
- 目标检测系列——Faster R-CNN原理详解
- Mathematical analysis_ Notes_ Chapter 8: multiple integral
- 【Node】npm、yarn、pnpm 区别
- 苏打粉是什么?
- Literacy Ethernet MII interface types Daquan MII, RMII, smii, gmii, rgmii, sgmii, XGMII, XAUI, rxaui
猜你喜欢
随机推荐
Matlab在线性代数中的应用(四):相似矩阵及二次型
Altimeter data knowledge point 2
Mathematical analysis_ Notes_ Chapter 8: multiple integral
Ros2 - workspace (V)
1290_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS
ModuleNotFoundError: No module named ‘picamera‘
Special training of C language array
ROS2——安装ROS2(三)
SOC_ SD_ DATA_ FSM
What if the DataGrid cannot see the table after connecting to the database
1290_FreeRTOS中prvTaskIsTaskSuspended()接口实现分析
Initialization of global and static variables
ROS2——topic话题(八)
Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
【软件测试】06 -- 软件测试的基本流程
一文揭开,测试外包公司的真实情况
苏打粉是什么?
Qu'est - ce que l'hydroxyde de sodium?
睿智的目标检测59——Pytorch Focal loss详解与在YoloV4当中的实现
C#学习笔记








