Dired Trick #1

Many people say that once you get the hang of Dired, you never use anything else. How true is this?

From a personal perspective I’d say that was true, but the key is in the first part of the sentence once you’ve got used to using Dired…

Here’s real world use for Dired.

C-x d to start Dired and navigate to a directory.

Here’s a directory into which a CD has been ripped. The track names haven’t been recognised.

/home/*****/Music/Ludwig van Beethoven/Beethoven- Symphonies Nos. 1 & 2:
total used in directory 108088 available 32870008
drwxrwxrwx 2 ***** ***** 4096 Jun 8 2009 .
drwxrwxrwx 4 ***** ***** 4096 Jan 10 2009 ..
-rwxr--r-- 1 ***** ***** 19510080 Sep 21 2010 01 Track 1.mp3
-rwxr--r-- 1 ***** ***** 12268125 Sep 21 2010 02 Track 2.mp3
-rwxr--r-- 1 ***** ***** 7567075 Sep 21 2010 03 Track 3.mp3
-rwxr--r-- 1 ***** ***** 11410580 Sep 21 2010 04 Track 4.mp3
-rwxr--r-- 1 ***** ***** 20195615 Sep 21 2010 05 Track 5.mp3
-rwxr--r-- 1 ***** ***** 19836565 Sep 21 2010 06 Track 6.mp3
-rwxr--r-- 1 ***** ***** 7501945 Sep 21 2010 07 Track 7.mp3
-rwxr--r-- 1 ***** ***** 12329080 Sep 21 2010 08 Track 8.mp3

I could rename each track using a GUI by right clicking on each one and changing the name. Dired mode is faster

C-x C-q to toggle read only. Now simply type the new names of the tracks directly into the buffer. C-c C-c when you’ve finished.

If you want to be more efficient, move the point to the T in Track 1 and press M-z 1 to zap-to-char 1, deleting everything up to including the 1, leaving the .mp3 intact. Now type in the new track name.

If you want to be really efficient, of course, you could use search and replace…

Related Posts

Dired Tricks #2

Emacs Snooker

The key to snooker isn’t where the coloured balls go, it’s where your white ball stops. You should always be thinking about setting up your next shot. Something similar holds when using Emacs. Where will the point (cursor) be when you’ve completed your current operation?

Consider the following commands:
M-u Convert to uppercase to the end of the word
M-l Convert to lowercase to the end of the word
M-c Capitalize word

Note that the point jumps to the end of the word when each command is called. This makes it easy to jump through a string of words, changing case or capitalizing as you wish.

Now consider the following

M– M-u Convert previous word to uppercase
M– M-l Convert previous word to lowercase
M– M-c Capitalize previous word
M– means (Alt) and –

Note that the point remains where it is, at the end of the word you’ve just converted. You can’t jump back through a series of words converting as you go.

It’s like the difference between hitting C-o and hitting Enter. At first glance they both appear to do the same thing, but look at the point…
(image: www.freeimages.co.uk)