lua 根据路径获取文件名
require "lfs" function dirpath(path)
for file in lfs.dir(path) do -- lfs.dir 根据路径获取该路径下的文件名
if file ~= '.' and file ~= '..' then
local f = (path .. '/'..file)
local attr = lfs.attributes(f) -- 该文件的各种属性
if attr.mode == "directory" then
print(f .. " --> " .. attr.mode)
dirpath(f)
else
print(f .. " --> " .. attr.mode)
end end
end
end
dirpath("/usr")
删除文件: os.remove(filepath)
文件属性 lfsattributes(filepath) 具体参数有下: modification
rdev
size
ino
mode file
access
blocks
nlink
uid
blksize
gid
permissions rw-r--r--
dev
change
lua 根据路径获取文件名的更多相关文章
- php根据路径获取文件名
<?php // 根据路径返回文件名 $path = 'J:\abc\defg\hijk\一个文件夹\lmn\opq'; $path = iconv("UTF-8", &qu ...
- shell 根据路径获取文件名和目录
path=/dir1/dir2/dir3/test.txt echo ${path##*/} 获取文件名 test.txtecho ${path##*.} 获取后缀 txt #不带后缀的文件名temp ...
- C#通过文件路径获取文件名小技巧
string fullPath = @"\WebSite1\Default.aspx"; string filename = System.IO.Path.GetFileName( ...
- C#通过文件路径获取文件名
string fullPath = @"\WebSite1\Default.aspx"; string filename = System.IO.Path.GetFileName( ...
- php文件路径获取文件名
物理截取: $file = '/www/htdocs/inc/lib.inc.php'; $filename = basename($file); echo $filename, '<br/&g ...
- PHP 文件路径获取文件名
物理截取 $file = '/www/htdocs/inc/lib.inc.php'; $filename = basename($file); echo $filename, '<br/> ...
- 在 SQL Server 中从完整路径提取文件名(sql 玩转文件路径)
四个函数: --1.根据路径获取文件名 -- ============================================= -- Author: Paul Griffin -- Crea ...
- python关于文件路径和文件名的操作
os.path.abspath(path) #返回绝对路径(包含文件名的全路径) os.path.basename(path) —— 去掉目录路径获取文件名 os.path.dirname(path) ...
- c#根据绝对路径获取 带后缀文件名、后缀名、文件名
zz C#根据绝对路径获取 带后缀文件名.后缀名.文件名 1.c#根据绝对路径获取 带后缀文件名.后缀名.文件名. string str =" F:\test\Default.aspx& ...
随机推荐
- 知识点总结 REACT
1.react中如何创建一个组件 ES6:class 组件名 extends Component{} ES5:var App=React.createClass({}) 2.render函数什么时候会 ...
- 【转】web.xml详解
转载:https://www.cnblogs.com/vanl/p/5737656.html. 一:web.xml加载过程 简单说一下,web.xml的加载过程.当我们启动一个WEB项目容器时,容器包 ...
- Jenkins的简介及安装
Jenkins介绍 Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能. 1. jenkins就是 ...
- MySQL实战45讲学习笔记:第二十二讲
一.引子 不知道你在实际运维过程中有没有碰到这样的情景:业务高峰期,生产环境的 MySQL 压力太大,没法正常响应,需要短期内.临时性地提升一些性能. 我以前做业务护航的时候,就偶尔会碰上这种场景.用 ...
- [LeetCode] 921. Minimum Add to Make Parentheses Valid 使括号有效的最少添加
Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', ...
- [LeetCode] 711. Number of Distinct Islands II 不同岛屿的个数之二
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...
- js中的require、define、export、import【转】
原文链接:https://www.cnblogs.com/libin-1/p/7127481.html 为什么有模块概念 理想情况下,开发者只需要实现核心的业务逻辑,其他都可以加载别人已经写好的模块. ...
- oracle--AWR,ADDM,ASH区别
一,ASH (Active Session History) ASH以V$SESSION为基础,每秒采样一次,记录活动会话等待的事件.不活动的会话不会采样,采样工作由新引入的后台进程MMNL来完成. ...
- 运维工程师打怪升级进阶之路 V2.0
在此之前,发布过两个版本: 运维工程师打怪升级之路 V1.0 版本发布 运维工程师打怪升级必经之路 V1.0.1 很多读者伙伴们反应总结的很系统.很全面,无论是0基础初学者,还是有基础的入门者,或者是 ...
- mtd-utils编译安装过程
git clone git://git.infradead.org/mtd-utils.git cd mtd-utils apt install -y libssl-dev libzlb libzst ...