Installation
$ brew install rename
参数
-v
- 显示文件重命名细节
$ rename -v 's/.txt/.log/' *.txt
a.txt renamed as a.log
b.txt renamed as b.log
c.txt renamed as c.log
Usage
批量将所有后缀为 .txt 的文件改为 .log
$ rename -v 's/.txt/.log/' *.txt
批量修改 .png文件的特定部分,由 ic_
改为 ic_setting_
$ rename 's/ic_/ic_setting_/' *.png
# e.g., ic_launcher.png -> ic_setting_launcher.png
批量修改文件的命名
$ rename 's/_setting//' *.png
# e.g., ic_setting_launcher.png -> ic_launcher.png
把文件名包含AA的文件的文件名中的AA替换成aa
$ rename "s/AA/aa/" *
把所有以.txt结尾的文件名的.txt删掉
$ rename "s//.txt//" *
批量添加文件后缀 - 把所有的文件名都以txt结尾
$ rename "s/$//.txt/" *
批量重命名
我们在编写程序时,往往希望读入的这些数据集的文件名是一种更简洁的形式,比如按照索引方式:1.mp4,2.mp4,3.mp4…,那么如何批量重命名一个文件夹下的文件名呢?方法很简单,只需要在linux的终端Terminal里面进入数据集的当前文件夹里面,直接输入以下命令即可:
$ i=1; for x in *; do mv x i.mp4; let i=i+1; done
Reference
FEATURED TAGS
algorithm
algorithmproblem
architecturalpattern
architecture
aws
c#
cachesystem
codis
compile
concurrentcontrol
database
dataformat
datastructure
debug
design
designpattern
distributedsystem
django
docker
domain
engineering
freebsd
git
golang
grafana
hackintosh
hadoop
hardware
hexo
http
hugo
ios
iot
java
javaee
javascript
kafka
kubernetes
linux
linuxcommand
linuxio
lock
macos
markdown
microservices
mysql
nas
network
networkprogramming
nginx
node.js
npm
oop
openwrt
operatingsystem
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software testing
spring
sql
systemdesign
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
xml
zookeeper