惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

拓源网

微信和QQ访问页面提示使用右上角浏览器打开 - 拓源网 [反调试]审查元素清空页面或重定向 - 拓源网 使用Python移除PDF编辑权限密码 - 拓源网 写一款《PPT将指定页面另存为》小工具 - 拓源网 让jquery代码只能在指定域名下运行的三种方法 - 拓源网 PPT拼图批量生成工具 - 拓源网 Deepseek微信聊天机器人 - 拓源网 使用Python自动抓取zblog文章到腾讯云大模型知识引擎LKE,投喂数据专属化自己的知识库 - 拓源网 deepseek生图指令 - 拓源网
批量替换文件名的powershell脚本 - 拓源网
2025-08-05 · via 拓源网

我们常常在按Ctrl键用鼠标单击选择多个文件时,不小心手抖或者鼠标不灵敏,会复制出来很多副本文件,第一时间Ctrl+Z可以撤销操作,当后续进行了其他操作回来再处理这些副本文件,可以用以下powershell脚本,将所有带“ - 副本”名称的文件全部删除。

打开需要批量替换文件名所在的文件夹,按住Shift键,右键点击文件夹空白处,选择“在此处打开 PowerShell 窗口”。

运行以下命令:

Get-ChildItem -File -Recurse | Where-Object { $_.Name -like "* - 副本*" } | Remove-Item

当然可以指定文件类型,如jpg文件:

Get-ChildItem -Filter *.jpg | Where-Object { $_.Name -like "* - 副本*" } | Remove-Item

如果不存在重复文件的情况,只希望批量修改文件名,可以用以下命令:

Get-ChildItem -Filter *.jpg | Rename-Item -NewName { $_.Name -replace " - 副本", "" }

这条命令会遍历当前文件夹下所有.jpg文件,并把文件名中的“ - 副本”字样删除,可自行修改需要替换的文件扩展名和要替换的文字内容。

需要注意的是,文件夹路径不能含有特殊字符。