批量重命名文件名称

目标:

copy all files .pdf to _0.pdf

推荐使用rename.ul或mmv

1. rename.ul

1
rename.ul -v -n ".pdf" "_0.pdf" *.pdf

2. bash

1
for f in *.pdf; do pre="${f%.pdf}"; echo mv -- "$f" "${pre}_0.pdf"; done

3. rename

1
rename -n 's/\.pdf$/_0$&/' *.pdf
  1. matches .pdf at the end of the filename
    1
    2. in the replacement, the match is prepended by ```_0```: ```_0$&
  1. drop -n for actual action

4. mmv

1
2
sudo apt-get install mmv
mmv '*.pdf' '#1_0.pdf'