rename files with vimv

· ahwx's blog


vimv #

example: i rename my pictures to {1...1000}.$extention #

Go into the folder where you want to bulk rename and enter the following Vim command. First remove any other names of any files if there are any, so that you get a list of file name extentions such as this:

1.png
2.jpg
3.jpg
4.jpg
5.png

You can do this easily using :%s and/or the V-Block editor, which you can use with Ctrl + V.

Now you can enter this command:

1:%s/^/\=printf('%-4d', line('.')) 

Other cool things you can do with Vim #

Convert all letters in the buffer to lowercase, I use this when managing mp3 files as I dislike each artist having their own style, I want everything to be lowercase. Go into normal mode and hit: ggVGu, this will go to the first line (gg), select (V, visual selection in line mode) everything (G, goes to end of file) and u (set all in selection to lowercase)