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))))

​#Emacs

Comments

(Please contact me if you want to remove your comment.)

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 😃.

https://framapic.org/T2Y5H4XHFI6t/FXTfyji9Cpi3.gif

https://framapic.org/T2Y5H4XHFI6t/FXTfyji9Cpi3.gif

– Damien Cassou 2016-05-19 18:10 UTC

Damien Cassou

---

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

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