DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Batch rename in zsh


There are many mp3 files with initial "Various - ...", like:

Various - Beethoven:Symphony No.5-Allegro Con Brio.mp3

Now I want to remove the "Various - " in the file name, to "Beethoven:Symphony No.5-Allegro Con Brio.mp3".

In zsh we have a tool called zmv can do this job. Firstly we have to use autoload zmv to activate it. Then use "-n" option to print the result without actually performing the rename operation. When it is ok, remove the -n option to rename all the files:

zmv -n '(*).mp3' '${1//Various\ -\ /}.mp3'
zmv '(*).mp3' '${1//Various\ -\ /}.mp3'

Ref: http://www.drbunsen.org/batch-file-renaming/



Published

Sep 24, 2013

Last Updated

Sep 24, 2013

Category

Tech

Tags

  • rename 1
  • zsh 5

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor