Okay, I think I misunderstood what you were asking for the first time 'round.
As I now understand it, you have a bunch of existing playlists which have tracks listed in The Right Order. You're looking for a way to rename the files themselves so they'll sort ascii-betically (ie., the way that the file explorer sorts them) in the same order as they are in the playlists. Is that correct?
If so, can you post one sample playlist?
Off the top of my head, though,
if each playlist just has a list of files in its own directory, it might be as simple as:
Code:
cat -n $playlist | while read number name ; do mv "$name" "$( echo `printf "%03d" $number` $name )" ; done
cat -n $playlist will spit out the playlist with line numbers pre-pended. You'll want to replace that with the actual playlist file's name (or a glob that will match all-and-only playlist files; '*m3u' might work).
while read number name will read that in, putting the first (whitespace-delimited) token into "number" and the rest into "name" (so, "number" will hold the track number, and "name" will hold the filename).
printf "%03d" $number will print out "number", with leading zeroes so that the number is 3 digits (or more) wide.
echo `printf "%03d" $number` $name will take that wider number (with the leading zeroes) and tack the filename on the end.
$( echo `printf "%03d" $number` $name ): the $() part is a command substitution, saying "do the stuff inside of the parentheses and put the result here"; the inside builds the destination file name, and the substitution puts that name in
mv's destination slot
mv "$name" "$( echo `printf "%03d" $number` $name )" actually moves the file from "name" to "xxx name".
So, that command line will read in the playlist with line numbers; for each line, it'll split apart the line number and file name, then move the file from "name" to "xxx name" (where "xxx" is the file number).
It will
only work the way you probably want it to work if the playlist is in the same directory as the files in the playlist.
It
will move files around; it would be a
very good idea to make a copy of the whole directory first, just in case. I have run that command on a small sample of files, but your 219 files may trigger weird things that my (very simple) sample set of files didn't.