当前位置:网站首页>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$")
边栏推荐
- Docker installs MySQL and uses Navicat to connect
- 程序中的负数存储及类型转换
- 现在有html文件,和用vs制作的mvc(连接了数据库),怎么两个相连?
- Application of MATLAB in Linear Algebra (4): similar matrix and quadratic form
- [node] differences among NPM, yarn and pnpm
- Ret2xx---- common CTF template proposition in PWN
- ImportError: No module named ‘Tkinter‘
- Ros2 - ros2 vs. ros1 (II)
- 并发编程 — 死锁排查及处理
- 网易To B,柔外刚中
猜你喜欢

PHY驱动调试之 --- MDIO/MDC接口22号和45号条款(一)

【软件测试】06 -- 软件测试的基本流程
![[software testing] 06 -- basic process of software testing](/img/fe/3d8b9b68f95ac7899ab87d6993284d.jpg)
[software testing] 06 -- basic process of software testing
![[node] NVM version management tool](/img/26/f13a2451c2f177a86bcb2920936468.png)
[node] NVM version management tool

程序中的负数存储及类型转换

Three body goal management notes
![[software testing] 03 -- overview of software testing](/img/1e/0b6458160e34e43f021ea4797de70a.jpg)
[software testing] 03 -- overview of software testing

1290_ Implementation analysis of prvtaskistasksuspended() interface in FreeRTOS

DataGrid offline installation of database driver

PHY drive commissioning --- mdio/mdc interface Clause 22 and 45 (I)
随机推荐
Chapter 2: try to implement a simple bean container
解读最早的草图-图像翻译工作SketchyGAN
Concurrent programming - deadlock troubleshooting and handling
Ros2 topic (VIII)
Initialization of global and static variables
ROS2——初识ROS2(一)
What is sodium hydroxide?
小米笔试真题一
Inftnews | drink tea and send virtual stocks? Analysis of Naixue's tea "coin issuance"
[software testing] 02 -- software defect management
Oracle code use
Ros2 - Service Service (IX)
Database SQL practice 3. Find the current salary details of the current leaders of each department and their corresponding department number Dept_ no
[vscode] recommended plug-ins
【Node】npm、yarn、pnpm 区别
Interpretation of the earliest sketches - image translation work sketchygan
npm install -g/--save/--save-dev的区别
Ros2 - install ros2 (III)
基于Cortex-M3、M4的GPIO口位带操作宏定义(可总线输入输出,可用于STM32、ADuCM4050等)
【软件测试】04 -- 软件测试与软件开发