快速正则表达式匹配模式并将其替换为 null/empty
我有一个包含大量文件的文件夹,我需要重命名它们。我正在使用批量/批量重命名实用程序: http://www.bulkrenameutility.co.uk /Download.php
它允许正则表达式模式匹配和替换。
以下是几个示例文件名:
- ...
- 04-067 - 我需要的文件名 (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-068 -我需要的文件名 (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-069 - 我需要的文件名称 (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-070 - 我需要的文件名称 (1943) (Aplha, Xtra , Info) [ExtraA] (15m34s).avi
- 04-071 - 我需要的文件名 (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-072 - 我需要的文件名 (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-073 - 我需要的文件名(1943)(Aplha、Xtra、Info)[ExtraA] (15m34s).avi
- ...
我需要删除 (19*
部分并保留 .avi
以便新名称如下:
- .. .
- 04-067 - 我需要的文件名称.avi
- 04-068 - 我需要的文件名称.avi
- 04-069 - 我需要的文件名称.avi
- 04-070 - 我需要的文件名称.avi
- 04-071 -我需要的文件名.avi
- 04-072 - 我需要的文件名.avi
- 04-073 - 我需要的文件名.avi
- ...
文件名有时也包含 (abc),但 (19 *
始终存在:
04-067 - 我需要的文件名称(彩色)(3D)(1943)(Aplha、Xtra、Info)[ExtraA] (15m34s).avi
对于这样的正则表达式有任何快速帮助吗?
更新: 这是一个图像(http://img542.imageshack.us/img542/6275/bulkrenameutility .png) :
问候。
I have a folder with a huge number of files and I need to rename them. I'm using a bulk/batch renaming utilty: http://www.bulkrenameutility.co.uk/Download.php
It allows for RegEx patern matching and replacing.
Here is are couple of sample file names:
- ...
- 04-067 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-068 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-069 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-070 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-071 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-072 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- 04-073 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi
- ...
I need to remove the (19*
part and keep the .avi
so that new names are as follows:
- ...
- 04-067 - Name of File I need.avi
- 04-068 - Name of File I need.avi
- 04-069 - Name of File I need.avi
- 04-070 - Name of File I need.avi
- 04-071 - Name of File I need.avi
- 04-072 - Name of File I need.avi
- 04-073 - Name of File I need.avi
- ...
The name of files sometimes contain a (abc) too but the (19*
are always present:
04-067 - Name of File I need (Colored) (3D) (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s)
.avi
Any quick help for such a regex?
Update:
Here is an image (http://img542.imageshack.us/img542/6275/bulkrenameutility.png) :
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
\s*\(19.*\.avi
替换为.avi
Replace
\s*\(19.*\.avi
with.avi
我不知道您所指的工具,但此正则表达式应该
在第一个括号之前有一个空格,然后将其替换为空字符串。也许“(”需要在您的工具中转义。
使用 sed 进行测试:
I don't know the tool you are referring to but this regexp should work
there is a space before the first parenthesis, and then replace it with an empty string. Perhaps "(" needs to be escaped in your tool.
tested using sed:
此正则表达式应匹配括号
/(\s*19.*\.avi$/i
之间包含年份的所有文件名。然后,将匹配的字符串替换为.avi
。This regex should match all the filenames containing a year between parentheses
/(\s*19.*\.avi$/i
. Then, replace the matched string with.avi
.