我需要重命名的文件示例:
microsoft-windows-languagefeatures-basic-bs-latn-ba-package_100e5dc9f1eb0cc3f9ef59c60dd24543827a6c48.cab
microsoft-windows-languagefeatures-basic-bn-in-package_679f41a31fa39e91da733edba47cc8e3cd8013d4.cab
microsoft-windows-languagefeatures-basic-bn-bd-package_81a64b49f357d8eef17d8797ddba200c04c9805e.cab
microsoft-windows-languagefeatures-basic-bg-bg-package_59a6ca257ed175d72efc6718f153837fb48d1890.cab
microsoft-windows-languagefeatures-basic-az-latn-az-package_943c512fe9e0917c6116d4f81a764f0144d8a67f.cab
microsoft-windows-languagefeatures-basic-as-in-package_e8363efa6389494eedc61f26057ab333d8c11a55.cab
microsoft-windows-languagefeatures-basic-ar-sa-package_fc97e593423319e11b7521f8076a5de21348e831.cab
microsoft-windows-languagefeatures-basic-af-za-package_b498b23dfb0271d34850f331fdaeffacf3d97ed5.cab
microsoft-windows-languagefeatures-basic-de-de-package_34de150bd496f5e06b7c9eee2227650c54b11a27.cab
microsoft-windows-languagefeatures-basic-da-dk-package_31a2dd00b08c9d7cdaba85c5c60777eaa75166bf.cab
microsoft-windows-languagefeatures-basic-cy-gb-package_065ebd6f0adcc91feb98e943b4599cc6b656ed05.cab
microsoft-windows-languagefeatures-basic-cs-cz-package_2eac7ee66be70c97d357ca70101e0c93af2387f1.cab
microsoft-windows-languagefeatures-basic-ca-es-package_437de767fb26329de81b3a92cd95e970a6d1e451.cab
我只想保留“basic-langcode”部分,但我不知道如何批量重命名文件以实现该结果。
另外,我希望通过适用于 Windows、Linux 和 MacOS 的方法来实现这一点,但这是一项额外要求。
答案1
您看过“批量重命名实用程序”吗?我曾使用它重命名多个文件,发现它非常有用且灵活。它需要一点时间来适应,但它附带了很好的说明,并且相当容易使用。试试吧!可以在这里找到它 - http://www.bulkrenameutility.co.uk
噢!顺便说一句...它是免费的!
答案2
在 Linux 中,重命名包(以前是Perl 包prename
) 有一个名为(的脚本/实用程序在 Debian 中它是命令rename
),并且作为 perl 脚本,您应该能够在任何计算机上运行它。它可以执行以下操作:
NAME
rename - renames multiple files
SYNOPSIS
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
DESCRIPTION
"rename" renames the filenames supplied according to the rule specified as
the first argument. The perlexpr argument is a Perl expression which is
expected to modify the $_ string in Perl for at least some of the filenames
specified. If a given filename is not modified by the expression, it will
not be renamed. If no filenames are given on the command line, filenames
will be read via standard input.
For example, to rename all files matching "*.bak" to strip the extension,
you might say
rename 's/\.bak$//' *.bak
To translate uppercase names to lower, you'd use
rename 'y/A-Z/a-z/' *
简单的方法是找到有关要“删除”的文件名的具体信息,也许运行两次以删除开头和结尾的内容。困难的方法是找到 perlexpr 匹配项,例如一个破折号,然后是两个小写字母字符,然后是一个破折号,后面可以随意跟着一些东西,然后再找到另一个破折号,两个小写字母字符破折号,然后将其重命名为匹配项。