在 Ubuntu 中将所有子目录中的文件名更改为小写 [英] Change filenames to lowercase in Ubuntu in all subdirectories
问题描述
我知道有人问过,但到目前为止我发现的还没有解决.我来的柜子是这样的:rename -n 'y[A-Z]/[a-z]/' *
适用于当前目录.我不太擅长 Linux 终端那又怎样我是否应该添加到此命令以将其应用于我所在的所有子目录中的所有文件,谢谢!
I know it's been asked but what I've found has not worked out so far.
The closet I came is this : rename -n 'y[A-Z]/[a-z]/' *
which works for the current directory. I'm not too good at Linux terminal so what
should I add to this command to apply it to all of the files in all the sub-directories from which I am in, thanks!
推荐答案
这是使用 find
和 tr
的一种方法:
Here's one way using find
and tr
:
for i in $(find . -type f -name "*[A-Z]*"); do mv "$i" "$(echo $i | tr A-Z a-z)"; done
编辑;添加:-name "*[A-Z]*"
这确保只找到大写字母的文件.例如,如果找到只有小写字母的文件并将其移动到同一文件中,mv
将显示 are the same file
错误.
This ensures that only files with capital letters are found. For example, if files with only lowercase letters are found and moved to the same file, mv
will display the are the same file
error.
这篇关于在 Ubuntu 中将所有子目录中的文件名更改为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!