renaming multiple files in a few seconds using Emacs wdired

I used to write a short script in case I need to rename a lot of files, following some logic.
For example, I have scanned many pages of a manual and got these files:
1.jpg
2.jpg

10.jpg
11.jpg

100.jpg
101.jpg

For acrobat to combine them into one pdf file, it’s better to have them in the correct order, but acrobat by default sort them as:
1.jpg
10.jpg
11.jpg

100.jpg
101.jpg

2.jpg

Then it’s easier for me to rename them into:
001.jpg
002.jpg

As I said, I used to write a short script to do this. But today Emacs taught me an faster alternative: wdired

According to the GNU Emacs Manual:
"Wdired is a special mode that allows you to perform file operations by editing the Dired buffer directly (the W in Wdired stands for writable.) To enter Wdired mode, type C-x C-q (dired-toggle-read-only) while in a Dired buffer. "

You can also enter wdired by M-x wdired-change-to-wdired-mode.

This mode allows you to change the properties file such as file names, permissions, by editing the dired buffer.

So for the above problem, I just simply use rectangle editing, and add the preceding 0 or 00 to the file names.

Emacs is truly great and a productivity booster!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s