Furiously Eclectic People

Full Version: It's late, I'm tired. Do my job for me.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a text file. Let's say it's:

Amazing Spider-Man 01

Amazing Spider-Man 02
Amazing Spider-Man 03
Amazing Spider-Man 04
Amazing Spider-Man 05
Amazing Spider-Man 07
Amazing Spider-Man 09
Batman 01
Batman 02
Batman 03
Batman 05
Batman 06
Batman 07
Batman 08
Batman 09
Batman 10
Batman 11

It isn't, but let's say it is.

What I want is a text fileĀ that reads:

Amazing Spider-Man 01-05, 07, 09
Batman 01-03, 05-11

LeadingĀ 0s are optional, but exist in the original file. Also, spaces after commas aren't strictly necessary.

I want to do this on a file over 10,000 lines long, so doing it by hand is out of the question.
Did you find a solution?