当前位置:网站首页>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;
}
}
}
边栏推荐
- HCIP,OSPF综合实验
- Prometheus+node exporter+grafana monitoring server system resources
- [QNX hypervisor 2.2 user manual]9 VM configuration reference
- MGRE实验
- 创建自签名证书, 对exe文件进行数字签名
- Sword *offer04 rebuild binary tree
- Scroll View implémente la mise à jour déroulante (empêche onload d'entrer dans la page de mise à jour initiale du Shell Triggered pour déclencher la mise à jour déroulante pour True)
- Sword *offer -- reverse order of linked list
- OSPF experiment
- docker redis
猜你喜欢

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

Matlab提取论文插图中原始数据—Fig2Data工具

制作 .Img 镜像文件

Sublime text 3 汉化+添加常用插件

Kubernetes deployment dashboard (visual interface)

B tree and b+ tree

Seektiger's okaleido has a big move. Will the STI of ecological pass break out?

kubernetes 部署 dashboard(可視化界面)

SkyWalking分布式系统应用程序性能监控工具-上

Project scenario: NVIDIA SMI unable to datemine the device handle for GPU 0000:01:00.0: unknown error
随机推荐
Memory forensics nssctf otterctf 2018 (replay)
Intelligent video monitoring solutions for elderly care institutions, using new technologies to help the intelligent supervision of nursing homes
Create a self signed certificate to digitally sign exe files
Description of TCP packet sticking problem code
J'ai choisi la mauvaise technologie au mauvais moment.
Axure implements addition, deletion, modification and query
Solve the problem that the double click of Google Chrome browser doesn't respond and can't be started (friendly testing)
Programmeur de cheval noir - test d'interface - test d'interface d'apprentissage de quatre jours - jour 4 - Postman lit des fichiers de données externes, lit des données de fichiers de données, IHRM P
vim常用命令
Easyexcel export case (only you can't think of it)
1000 okaleido tiger launched binance NFT, triggering a rush to buy
OSPF experiment
Solve the problem that MySQL inserts Chinese garbled code into the table
Tutorial on principles and applications of database system (043) -- MySQL query (V): Sorting Query Results
【複盤】關於我在錯誤的時間選錯了技術這件事
Tutorial on principles and applications of database system (045) -- MySQL query (VII): aggregate function
An article teaches you the basic use of kubernetes
EasyExcel导出案例(只有你想不到)
Dark horse programmer - interface test - four day learning interface test - day 4 - postman reads external data files, reads data files, IHRM project practice, employee management module, adds employe
[QNX hypervisor 2.2 user manual]9 VM configuration reference