[Ilugc] [Help] Renaming files through bash shell scripts

  • From: baskar@xxxxxxxxxxxx (Baskar Selvaraj)
  • Date: Wed, 28 Oct 2015 17:38:28 +0530

On Wed, Oct 28, 2015 at 3:03 PM, Shakthi Kannan <shakthimaan at gmail.com>
wrote:

Hi,

--- On Wed, Oct 28, 2015 at 2:55 PM, Baskar Selvaraj
<baskar at linuxpert.in> wrote:
| The scripts works, but the results were different, if the value
after L is < 10.
\--

That is the question I had asked in my previous reply. What should be
the expected behavior in such a case?


There could be 'n' number of modules (referred as M) and those modules may
have 'n' no.of number of lectures (referred as L).

Now the requirement is to remove the modules from the filenames and have
only lectures in consecutive numerical order

If the directory has files names like this,

M1L1.mp4
M1L2.mp4
M1L3.mp4
M2L1.mp4
M2L2.mp4
M2L3.mp4
M2L4.mp4
M3L1.mp4
M3L2.mp4

Then, the resulting file list should be as below (were M followed by 'n'
value can be removed)

L1.mp4
L2.mp4
L3.mp4
L4.mp4 (here M2L1 should automatically get renamed to L4)
L5.mp4
L6.mp4
L7.mp4
L8.mp4 (here M3L1 again should automatically get renamed to L8)
L9.mp4

S. Baskar

Other related posts: