Re: [Help] Renaming files through bash shell scripts

Shakthi Kannan <[email protected]>
Newsgroups gmane.org.user-groups.linux.ilugc
Message-ID <CABG-yt2_mnQdbr2+Q0x5Af_exEsC_7zB9Bc4hb0Y-PfOjFYGDQ@mail.gmail.com>
Hi,

--- On Wed, Oct 28, 2015 at 12:56 PM, Baskar Selvaraj
<baskar-FaTCxNPFk8w/[email protected]> wrote:
| M2L01.mp4 should be renamed to M2L11.mp4 and
| M3L01.mp4 should be renamed to M3L21.mp4
\--

M1L10.mp4 can be renamed to M1L00.mp4? Here is a quickly hacked up Ruby script:

=== test.rb ===

#!/usr/bin/env ruby

Dir.glob("*.mp4").each do |f|
  new_f = f.dup
  new_f[3] = (f[1].to_i - 1).to_s

  File.rename(f, new_f)
end

=== END ===

SK

-- 
Shakthi Kannan
http://www.shakthimaan.com
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.