快速正则表达式匹配模式并将其替换为 null/empty

发布于 2024-11-15 09:06:18 字数 1669 浏览 7 评论 0原文

我有一个包含大量文件的文件夹,我需要重命名它们。我正在使用批量/批量重命名实用程序: 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) : Screenshot

Regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

遗心遗梦遗幸福 2024-11-22 09:06:18

\s*\(19.*\.avi 替换为 .avi

Replace \s*\(19.*\.avi with .avi

计㈡愣 2024-11-22 09:06:18

我不知道您所指的工具,但此正则表达式应该

/ (.*)/

在第一个括号之前有一个空格,然后将其替换为空字符串。也许“(”需要在您的工具中转义。

使用 sed 进行测试:

$ echo '04-067 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi' | sed 's/ (.*)//'
04-067 - Name of File I need.avi

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:

$ echo '04-067 - Name of File I need (1943) (Aplha, Xtra, Info) [ExtraA] (15m34s).avi' | sed 's/ (.*)//'
04-067 - Name of File I need.avi
日记撕了你也走了 2024-11-22 09:06:18

此正则表达式应匹配括号 /(\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 .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文