当前位置:网站首页>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$")
边栏推荐
- Database SQL practice 4. Find the last of employees in all assigned departments_ Name and first_ name
- IPage能正常显示数据,但是total一直等于0
- 【obs】x264编码:“buffer_size“
- Powermanagerservice (I) - initialization
- Use of Pai platform
- What does soda ash do?
- ROS2——topic话题(八)
- 全局变量和静态变量的初始化
- 苏打粉是什么?
- PHY drive commissioning --- mdio/mdc interface Clause 22 and 45 (I)
猜你喜欢
[software testing] 02 -- software defect management
An article was opened to test the real situation of outsourcing companies
ROS2——功能包(六)
postmessage通信
Build a microservice cluster environment locally and learn to deploy automatically
扫盲-以太网MII接口类型大全-MII、RMII、SMII、GMII、RGMII、SGMII、XGMII、XAUI、RXAUI
Inftnews | drink tea and send virtual stocks? Analysis of Naixue's tea "coin issuance"
Pytorch has been installed in anaconda, and pycharm normally runs code, but vs code displays no module named 'torch‘
[software testing] 04 -- software testing and software development
【软件测试】02 -- 软件缺陷管理
随机推荐
[idea] efficient plug-in save actions to improve your work efficiency
数学分析_笔记_第8章:重积分
[software testing] 02 -- software defect management
Steps and FAQs of connecting windows Navicat to Alibaba cloud server MySQL
What does soda ash do?
乐鑫面试流程
Spinningup drawing curve
[tf] Unknown: Failed to get convolution algorithm. This is probably because cuDNN failed to initial
ROS2——topic话题(八)
mingling
Executealways of unity is replacing executeineditmode
[software testing] 04 -- software testing and software development
ROS2——node节点(七)
[untitled]
小米笔试真题一
PHY驱动调试之 --- MDIO/MDC接口22号和45号条款(一)
Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
全局变量和静态变量的初始化
Ros2 - node (VII)
ROS2——ROS2对比ROS1(二)