blog

12020-10-22

SEAN K.H. LIAO

renaming

Maybe if I write this down I will actually remember next time

shell expansion

uses parameter expansion

quick:

for f in *.txt; do
  mv $f "${f%txt}md"
done

# or with find for more precise targetting
find . -name '*.txt' -exec sh -c 'f={}; mv $f ${f%txt}md'
zmv

a zsh module in other functions

zmv '(*).txt' '$1.md'

rename

the one that comes with util-linux on Arch, takes a pattern and what to replace it with and some files, super undocumented

rename md txt *

perl-rename

basically sed for file names

perl-rename 's/(.*).md/\1.txt/' *