in General, Software

Scripting

I needed to rename over 3000 files across several thousand directories the other day, and sure as hell wasn’t going to do it by hand. This was to change the name of the file used to show the cover art for my albums from “cover.jpg” to “folder.jpg”. For my benefit, should I need to do this again, here’s the Windows command script that’ll do the job:

for /r %i in (cover.jpg) do @rename "%i" folder.jpg

Simple. cover.jpg is the file you want to find, and folder.jpg is what you want to rename it to.

If I had thought it through properly I’d have written a script that actually found all the cover.jpg files then ran the rename against that list. This script actually attempts to rename the file even if it isn’t in the directory it’s looking at. This is less of a problem for me as the majority of the folders do contain a cover.jpg. ymmv.

Anyway, this is for my (and Phil’s) benefit rather than anyone elses! :P