我正在重命名文件和目录.基本上,我想要做的就是去掉空格,并用下划线替换它们,最后改成小写.我一次可以执行一个命令:$重命名“ s / / _ / g” *,然后是小写命令.但是,我正在努力实现所有这些目标.最重要的是,删除空格并用_代替,但不会小写.怎么会?
find /temp/ -depth -name "* *" -execdir rename 's/ /_/g; s,,?; ‘
原始文件名:
test FILE .txt
结果:(如果末尾有空格,请取出)
test_file.txt
解决方法:
rename 's/ +\././; y/A-Z /a-z_/'
或者,结合查找:
find /temp/ -depth -name "* *" -exec rename 's/ +\././; y/A-Z /a-z_/' {} +
find /temp/ -depth -name "* *" -type f -exec rename 's/ +\././; y/A-Z /a-z_/' {} +
简称
Would it be possible to rename the file with the last three characters
of the original file for example from big Dog.txt to dog.txt?
是.使用此重命名命令:
rename 's/ +\././; y/A-Z /a-z_/; s/[^.]*([^.]{3})/$1/'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。