当前位置:网站首页>BAT代码:批量文件下划线重命名
BAT代码:批量文件下划线重命名
2022-07-24 01:16:00 【派圣】
话不多说,直接上图,你们就知道是不是自己想要的代码了
我需要让目录下的文件全部加上“_简历”的后缀,方便归档处理
文件截图:

代码运行:

运行结果:

规则很清晰哈,就不多做解释!
代码如下:
<# :
cls&echo off&cd /d "%~dp0"&rem 编码ANSI
set "current=%cd%"
powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText(\"%~f0\",[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
pause
exit
#>
$suffix="_简历"
$current=get-item -literal $env:current;
[email protected](dir -literal $current|?{('.bat' -ne $_.Extension) -and ($_ -is [System.IO.FileInfo])});
for($i=0;$i -lt $files.length;$i++){
$m=[regex]::match($files[$i].BaseName.replace($suffix, ''), '[\u4E00-\u9FA5]+');
if($m.Success){
$newname=$m.groups[0].value+$suffix+$files[$i].Extension;
if($newname -ne $files[$i].Name){
$newfile=$files[$i].Directory.FullName+'\'+$newname;
write-host ($files[$i].Name+' --> '+$newname);
move-item -literal $files[$i].FullName $newfile -ErrorAction SilentlyContinue;
}
}
}
边栏推荐
- ACL——net
- Easyexcel export case (only you can't think of it)
- WinVerifyTrust调用返回80096005错误,时间戳签名或证书无法验证或已损坏
- Tutorial on principles and applications of database system (052) -- data integrity of MySQL (XIV): crosstab query (row column conversion)
- Graphic pipeline (I) post-processing stage alpha test template test depth test mix
- Matlab提取论文插图中原始数据—Fig2Data工具
- High voltage technology learning summary
- How to solve cnpm stuck during execution?
- Source code installation and use of APIs IX
- The problem that all values are the same occurs after golang for range traverses and assigns values to the dictionary
猜你喜欢

HCIP,OSPF综合实验
For data security reasons, the Dutch Ministry of Education asked schools to suspend the use of Chrome browser

黑馬程序員-接口測試-四天學習接口測試-第四天-Postman讀取外部數據文件,讀取數據文件數據,iHRM項目實戰,員工管理模塊,添加員工,批量運行測試用例,生成測試報告,

Polymer synthesis technology

Idea hot deployment (hot load)

1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮

Group chat room based on UDP

Form resume

Hcia-01 initial understanding of the Internet

HCIP第六天_特殊区域综合实验
随机推荐
Off screen rendering & FBO
[freeswitch development practice] column introduction
scroll-view实现下拉刷新(避免onload进入页面初始refresher-triggered为true触发下拉问题)
High voltage technology test questions and answers
docker redis
vim常用命令
数字化转型时代的企业数据新基建 | 爱分析报告
Notes: middle order traversal of binary trees (three solutions - recursion, iteration, Morris)
IDEA 编译器 设置方法之间分割线隔开
Kubernets déploiement du tableau de bord (interface visuelle)
Tutorial on principles and applications of database system (045) -- MySQL query (VII): aggregate function
[QNX Hypervisor 2.2用户手册]9.1 配置变量
制作 .Img 镜像文件
Matlab提取论文插图中原始数据—Fig2Data工具
C语言力扣第53题之最大子数组和。动态规划与分治
ACL——net
Seektiger's okaleido has a big move. Will the STI of ecological pass break out?
128. 最长连续序列
About redis: there is still a risk of data loss after redis sets data persistence
爬虫请求库的使用2