2016-05-18 Renaming Files

I had a bunch of files named like this, from various albums.

Cure - [1984] The top - 01 - Shake dog shake.mp3
Cure - [1984] The top - 02 - Bird mad girl.mp3
Cure - [1984] The top - 03 - Wailing wall.mp3

I wanted to move them into subdirectories, one for each album.

(dolist (file (directory-files "c:/Users/asc/Music/The Cure" t "\\.mp3$"))
  (let* ((name (file-name-nondirectory file))
	 (data (split-string name " - "))
	 (album (nth 1 data)))
    (unless (file-directory-p (concat "c:/Users/asc/Music/The Cure/" album))
      (make-directory (concat "c:/Users/asc/Music/The Cure/" album)))
    (rename-file file (concat "c:/Users/asc/Music/The Cure/" album "/" name))))



If your files have ID3 tags, you can do some thing like this, too:

exiftool '-filename<${Artist;} - ${Year} - ${Album}/${Track;} ${Artist;} - ${Title;}.%e' **.mp3

– Sam 2016-05-18 11:54 UTC

Nice! And using exiftool! :)

– Alex Schroeder 2016-05-18 13:17 UTC

A graphic alternative is exfalso (from quodlibet music player).

– Anonymous 2016-05-19 09:58 UTC

Here is a way to do it combining dired, wdired and multiple-cursors. This approach requires the existence of the album directory which might not make it particularly useful for your exact use case. Still, I find it cool and so should you :-).

Damien Cassou 2016-05-19 18:10 UTC

Very cool. And a nice video on top. Thumbs up!

– Alex Schroeder 2016-05-21 06:33 UTC

Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.