今天在wsl系统中尝试使用rename将部分文件名中的部分小写字母改为大写字母,但直接修改时一直失败:
$ rename -n 's/h2o/H2O/' *
F1+h2o-0-4h-1.lsm not renamed: F1+H2O-0-4h-1.lsm already exists
F1+h2o-0-4h-2.lsm not renamed: F1+H2O-0-4h-2.lsm already exists
F1+h2o-MG-4h-1.lsm not renamed: F1+H2O-MG-4h-1.lsm already exists
$ rename -n 's/(h2o)/\U$1/' *
F1+h2o-0-4h-1.lsm not renamed: F1+H2O-0-4h-1.lsm already exists
F1+h2o-0-4h-2.lsm not renamed: F1+H2O-0-4h-2.lsm already exists
F1+h2o-MG-4h-1.lsm not renamed: F1+H2O-MG-4h-1.lsm already exists
$ rename -n 'y/h2o/H2O/' *
F1+0-1h-1.lsm not renamed: F1+0-1H-1.lsm already exists
F1+0-1h-2.lsm not renamed: F1+0-1H-2.lsm already exists
F1+CK-4h-1.lsm not renamed: F1+CK-4H-1.lsm already exists
...
最后无奈,使用了一种取巧的方法,即先将目标字段替换成其他字段,再将其重命名:
$ rename 's/h2o/H3O/' *
$ rename 's/H3O/H2O/' *
然后就成功了,真是无语。