本文介绍了批处理文件,用于将文件名转换为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个批处理文件才能将文件夹及其子文件夹中的所有文件转换为小写字母.例如:

I need a batch-file to convert all files in a folder and its subfolders to lowercase. For example:

Here Is StackOverflow.txt

here is stackoverflow.txt

一个文件名位于括号中.是否有可能忽略它并使其保持先前状态?例如

A piece of the file name is in the bracket. Is it possible to neglect it and leave it on its previous state? e.g.

Here Is [A WEBSITE CALLED] StackOverflow.txt

here is [A WEBSITE CALLED] stackoverflow.txt

推荐答案

通过 JREN.BAT -混合JScript/批处理脚本,可通过正则表达式替换来重命名文件. JREN.BAT是纯脚本,可​​以从XP开始在任何Windows计算机上本地运行.

Easily done with JREN.BAT - a hybrid JScript/batch script that renames files via regular expression replacement. JREN.BAT is pure script that runs natively on any Windows machine from XP onward.

要将所有文件名简单地转换为小写:

To simply convert all file names to lower case:

jren "^" "" /l /s

如果您希望方括号之间的所有文本均为大写,而其他所有内容均为小写,则只需使用两个命令即可轻松实现

If you want all text between square brackets to be upper case, and everything else to be lower case, then it is easily done with two commands

jren "^" "" /l /s
jren "[.+?]" "uc($0)" /j /s

如果要保留方括号之间所有文本的原始大小写,并将其他所有内容都转换为小写,则需要更复杂的正则表达式和替换字符串.

If you want to preserve the original case of all text between square brackets, and convert everything else to lower case, then it takes a more complicated regular expression and replacement string.

jren "([^[]*)(\[.*?\])*" "lc($1?$1:'')+($2?$2:'')" /j /s

由于JREN是批处理脚本,因此如果要在另一个批处理脚本中使用该命令,则必须使用CALL JREN.

Since JREN is a batch script, you must use CALL JREN if you want to use the command within another batch script.

使用jren /?获取有关所有可用选项的帮助.

Use jren /? to get help on all available options.

这篇关于批处理文件,用于将文件名转换为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 13:26
查看更多