在 Ubuntu 中将所有子目录中的文件名更改为小写 [英] Change filenames to lowercase in Ubuntu in all subdirectories

查看:54
本文介绍了在 Ubuntu 中将所有子目录中的文件名更改为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有人问过,但到目前为止我发现的还没有解决.我来的柜子是这样的: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!

推荐答案

这是使用 findtr 的一种方法:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆