Identifying multi-disc sets from terminal (to facilitate renaming files)

To maximise chances of album identification Roon likes filenames from multi-disc sets to start with “discnumber-track”. This caused me issues as in most cases I’d opted to dispense with the concept of a disc and simply numbered tracks sequentially from 1…n where n is the total number of tracks in the multi-disc or box set. As I’ve got a somewhat large music collection I needed a way to identify folders containing more than a single disc. When ripping I retained cuesheets, so a simple solution to at least identify the culprits is the following bash script:

[code]
#!/bin/bash

find -type d | while read dir; do
count=$(find “$dir” -iname *.cue | wc -l)
echo “$dir $count”
done[/code]
Run it from the parent folder of your music collection and it’ll list each folder in the tree and the corresponding .cue count which you can then sort to enable you to browse the folders with more than one cuesheet to inspect the filename convention you used and to make any necessary changes. Output can be redirected to a file using > targetfile

If you’d prefer to list only folders containing two or more .cue files you can run the following script instead:

find . -type d | while read xdir; do xtotal=$(find "${xdir}" -type f -name *.cue | wc -l) if test $xtotal -gt 1 then echo "${xdir} : ${xtotal}" fi done

1 Like