当前位置:网站首页>Bat Code: batch file underline rename
Bat Code: batch file underline rename
2022-07-24 01:19:00 【Paisheng】
Don't talk much , Directly above , You will know whether it is the code you want 
I need to add all the files in the directory “_ resume ” The suffix , Convenient for archiving
File capture :

Code runs :

Running results :

The rules are very clear, huh , No more explanation !
The code is as follows :
<# :
cls&echo off&cd /d "%~dp0"&rem code ANSI
set "current=%cd%"
powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText(\"%~f0\",[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
pause
exit
#>
$suffix="_ resume "
$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第十一天笔记
- 好大夫问诊-俞驰-口腔信息
- 【FreeSwitch开发实践】专栏简介
- Dynamic rip configuration
- [QNX hypervisor 2.2 user manual]9 VM configuration reference
- docker mysql
- [reply] about the fact that I chose the wrong technology at the wrong time
- What impact does the European "gas shortage" have on China?
- Idea setting automatic package import and useless package deletion
- 数字化转型时代的企业数据新基建 | 爱分析报告
猜你喜欢

Navicat for MySQL installation tutorial

Sparksql design and introduction, 220722,

Prometheus operator user guide notes

HCIP第六天_特殊区域综合实验

LVS load balancing scheduling principle and configuration method

New infrastructure of enterprise data in the era of digital transformation | love Analysis Report

Good doctor consultation - Yu Chi - oral information

ACL——net

C language database: an online dictionary based on TCP multi process, with detailed steps illustrated. Welcome to watch it

Linx link, first level directory, redirection, CP and MV
随机推荐
How to troubleshoot the problem that VPN server cannot forward
面试题之:ArrayList和LinkedList有哪些区别
2022全球开发者薪资曝光:中国排第19名,平均年薪23,790美元
Redis - basic concept
【云原生之kubernetes】kubernetes集群下的Deployment高级资源对象管理
1000 okaleido tiger launched binance NFT, triggering a rush to buy
J'ai choisi la mauvaise technologie au mauvais moment.
HCIP第十天笔记
Kubernetes deployment dashboard (visual interface)
Sublime text 3 汉化+添加常用插件
Answer to the short answer question of polymer synthesis technology
High voltage technical examination questions with answers
HCIA的复习
Concept, key points and summary of postgraduate entrance examination in Polymer Physics
MySQL interview questions
Jianzhi offer 05 two stacks to realize the queue
Socket basic knowledge and various usage scenarios
Explanation of terms in Polymer Physics
SkyWalking分布式系统应用程序性能监控工具-上
Three usages of synchronized keywords in vernacular