Rename files sequentially
by snowman81 from LinuxQuestions.org on (#4VZ2Y)
I'm looking at the rename utility but I can't figure out how to rename files with the pattern I want. For example, I have the following innocuous file names:
DBZ.-.001.-.The.New.Threat.mp4*
DBZ.-.002.-.Reunions.mp4
etc.
And I want to replace everything between the dashes with S1E1, S1E2, etc.
I found an example from Google but am unsure how to adapt it to my situation.
Code:rename -n 'our $i; s/_.*/sprintf("_%03d.png", $i++)/e' *.pngMaybe replace everything between dashes with Code:S$nE$i, n++, i++?


DBZ.-.001.-.The.New.Threat.mp4*
DBZ.-.002.-.Reunions.mp4
etc.
And I want to replace everything between the dashes with S1E1, S1E2, etc.
I found an example from Google but am unsure how to adapt it to my situation.
Code:rename -n 'our $i; s/_.*/sprintf("_%03d.png", $i++)/e' *.pngMaybe replace everything between dashes with Code:S$nE$i, n++, i++?