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

查看:101
本文介绍了在所有子目录中的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天全站免登陆