Understanding rename/sprintf
by snowman81 from LinuxQuestions.org on (#5EQ72)
I'm having trouble understanding the following statement. I am renaming a directory of files which are episodes of a TV show where the format is The.Blah.Season.01.Episode.01.-.Pilot.mp4
The line I am using is this Code:rename -n -- 's/.*(\d+).*(\d+)/sprintf "S%02dE%02d.mp4", $1, $2/e' *.mp4So the -n is a dry run and doesn't make a change. The Code:s/.*(\d+).*(\d+) looks like it's using sed and a regex that finds the first and second occurrence of digits. The last part just does all these actions on any mp4 in the directory. The middle bit about sprintf I know controls the season/episode numbers but I'm getting confused when I try to look it up. Is the C version different from Java and so on?
When I run the command it looks like it sequentially increases the season number and the episode number is wrong. That first file shows up as S01E04.mp4
A) I don't understand where the part is that makes the season number increase.
and
B) Is there a way to keep the show name and episode name and only have the season and episode number show up as xxx.S01.E01.xxx


The line I am using is this Code:rename -n -- 's/.*(\d+).*(\d+)/sprintf "S%02dE%02d.mp4", $1, $2/e' *.mp4So the -n is a dry run and doesn't make a change. The Code:s/.*(\d+).*(\d+) looks like it's using sed and a regex that finds the first and second occurrence of digits. The last part just does all these actions on any mp4 in the directory. The middle bit about sprintf I know controls the season/episode numbers but I'm getting confused when I try to look it up. Is the C version different from Java and so on?
When I run the command it looks like it sequentially increases the season number and the episode number is wrong. That first file shows up as S01E04.mp4
A) I don't understand where the part is that makes the season number increase.
and
B) Is there a way to keep the show name and episode name and only have the season and episode number show up as xxx.S01.E01.xxx