[Bash] Batch Rename Every File in a Directory with zsh

Renaming every file in a directory with zsh is a common scenario when you're working with a series of related files. Using zsh's "for" loop, you can access the name of every file. Then using zsh's string replacement syntax of ${name/replace/with) you can adjust the file names.

for file in ./*
    mv $file ${file/-[string to remove]/[new string to add]}

If you just want to move string, for example, there is an extra "processed" string in the filename:

for file in ./*
    mv $file ${file/-processed/}
原文地址:https://www.cnblogs.com/Answer1215/p/13387354.html