当前位置:网站首页>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$")
边栏推荐
猜你喜欢
Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
Build a microservice cluster environment locally and learn to deploy automatically
Jenkins reported an error. Illegal character: '\ufeff'. Class, interface or enum are required
Netease to B, soft outside, hard in
【软件测试】03 -- 软件测试概述
三体目标管理笔记
【无标题】
Ros2 - install ros2 (III)
ROS2——Service服务(九)
网易To B,柔外刚中
随机推荐
[vscode] search using regular expressions
mingling
ModuleNotFoundError: No module named ‘picamera‘
数学分析_笔记_第8章:重积分
Application of MATLAB in Linear Algebra (4): similar matrix and quadratic form
[OBS] x264 Code: "buffer_size“
2022.06.27_每日一题
Empire help
Binary search (half search)
SD_ CMD_ SEND_ SHIFT_ REGISTER
【软件测试】05 -- 软件测试的原则
ROS2——安装ROS2(三)
Import CV2, prompt importerror: libcblas so. 3: cannot open shared object file: No such file or directory
Interpretation of the earliest sketches - image translation work sketchygan
Now there are HTML files and MVC made with vs (connected to the database). How can they be connected?
Chapter 2: try to implement a simple bean container
一文揭开,测试外包公司的真实情况
What is soda?
【idea】Could not autowire. No beans of xxx type found
Lexin interview process