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

2015-10-28 Thread Baskar Selvaraj
On Wed, Oct 28, 2015 at 3:03 PM, Shakthi Kannan 
wrote:

> Hi,
>
> --- On Wed, Oct 28, 2015 at 2:55 PM, Baskar Selvaraj
>  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
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines


Re: [Ilugc] [[OFF-TOPIC]] Block pop-ups in browsers on tablets/phones

2015-10-28 Thread Srikanth Lakshmanan
Hi,

On 20 October 2015 at 11:11, sahil साहिल 
wrote:

> I am struggling to block pop-ups while searching on my Tablet on
> Chrome/Firefox browsers. Sometimes it is so disturbing and annoying while I
> search something along with kids and all of sudden some obscene sites
> comes. Do you guys have any way to stop such pop-ups while searching on
> tablets as no pop-up blocker works on browsers on tablets/smart-phones?
>

Although I have not been successful in my attempts to block ads at router
level, you can try flashing openwrt / gargoyle on your router which have
router level blocking of ads (based on blocking lists). HTH


-- 
Regards
Srikanth.L
http://j.mp/SrikanthL
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines

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

2015-10-28 Thread Shakthi Kannan
Hi,

--- On Wed, Oct 28, 2015 at 5:38 PM, Baskar Selvaraj
 wrote:
| Now the requirement is to remove the modules from the filenames and have
| only lectures in consecutive numerical order
|
| M1L1.mp4
| M1L2.mp4
| ...
\--

New requirements! This is not what you mentioned in your initial
e-mail (where it was M1L01.mp4, M1L02.mp4 etc).

---
| Then, the resulting file list should be as below (were M followed by 'n'
| value can be removed)
|
| L4.mp4 (here M2L1 should automatically get renamed to L4)
\--

Yet again, new requirements!

I'd suggest you spend some time learning a scripting language, like
Ruby, and hack the existing script to suit your needs.

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


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

2015-10-28 Thread Baskar Selvaraj
Dear all,

I am looking for a simplified solution for renaming files through shell scripts.

I need the file names in continuous numerical order, i.e. from
M?L01.mp4 to M?L30.mp4

So, the file

M2L01.mp4 should be renamed to M2L11.mp4 and
M3L01.mp4 should be renamed to M3L21.mp4

M1L01.mp4
M1L02.mp4
M1L03.mp4
M1L04.mp4
M1L05.mp4
M1L06.mp4
M1L07.mp4
M1L08.mp4
M1L09.mp4
M1L10.mp4
* M2L01.mp4
M2L02.mp4
M2L03.mp4
M2L04.mp4
M2L05.mp4
M2L06.mp4
M2L07.mp4
M2L08.mp4
M2L09.mp4
M2L10.mp4
* M3L01.mp4
M3L02.mp4
M3L03.mp4
M3L04.mp4
M3L05.mp4
M3L06.mp4
M3L07.mp4
M3L08.mp4
M3L09.mp4
M3L10.mp4

Any help would be appreciated.

-- 
S. Baskar

Blog: https://linuxbaskar.wordpress.com
Twitter  : http://twitter.com/linuxbaskar
LinkedIN : http://www.linkedin.com/pub/baskar-selvaraj/21/881/b29
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines


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

2015-10-28 Thread Shakthi Kannan
Hi,

--- On Wed, Oct 28, 2015 at 9:24 PM, Baskar Selvaraj
 wrote:
| Thanks, it worked.
\--

Did you understand what the script did?

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


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

2015-10-28 Thread Shakthi Kannan
Hi,

--- On Wed, Oct 28, 2015 at 9:49 PM, Baskar Selvaraj
 wrote:
| Ruby script: No (as I have learn ruby)
\--

Please take some time to learn. For a start:

  https://www.ruby-lang.org/en/documentation/quickstart/

  http://tryruby.org/levels/1/challenges/0

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


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

2015-10-28 Thread Baskar Selvaraj
On 10/28/15, Vinoth Marimuthu  wrote:
> Hi Baskar,
>
> you can try this
>
> i=1
> cd *test*
> for name in `ls | sort`;
> do
> temp=`echo $name | cut -c 1-3`;
> if [ $i -lt 10 ]
> then
> newname=$temp;
> newname+="0$i.mp4";
> echo $name renamed to $newname;
> mv $name $newname
> else
> newname="$temp$i.mp4";
> echo $name renamed to $newname;
> mv $name $newname
> fi
> i=$((i+1));
> done
> cd ..
>
> change it to directory you want.
>

Thanks, it worked.

S. Baskar
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines


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

2015-10-28 Thread Baskar Selvaraj
> | Now the requirement is to remove the modules from the filenames and have
> | only lectures in consecutive numerical order
> |
> | M1L1.mp4
> | M1L2.mp4
> | ...
> \--
>
> New requirements! This is not what you mentioned in your initial
> e-mail (where it was M1L01.mp4, M1L02.mp4 etc).
>

Sorry for my mistake.  What I mentioned in the initial e-mail was
correct.  It was M1L01.mp4 and M1L02.mp4 only.

S. Baskar.
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines


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

2015-10-28 Thread Baskar Selvaraj
On 10/28/15, Shakthi Kannan  wrote:
> Hi,
>
> --- On Wed, Oct 28, 2015 at 9:24 PM, Baskar Selvaraj
>  wrote:
> | Thanks, it worked.
> \--
>
> Did you understand what the script did?

Bash script: Yes
Ruby script: No (as I have learn ruby)

S. Baskar
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines


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

2015-10-28 Thread Shakthi Kannan
Hi,

--- On Wed, Oct 28, 2015 at 12:56 PM, Baskar Selvaraj
 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


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

2015-10-28 Thread Baskar Selvaraj
> === 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 ===

Hi,

Thanks for the script

The scripts works, but the results were different, if the value after L is < 10.

input:

M1L01.mp4
M1L02.mp4
M1L03.mp4
M1L04.mp4
M1L05.mp4
M2L01.mp4
M2L02.mp4
M2L03.mp4
M2L04.mp4
M2L05.mp4
M3L01.mp4
M3L02.mp4
M3L03.mp4
M3L04.mp4
M3L05.mp4

Output:

M1L01.mp4
M1L02.mp4
M1L03.mp4
M1L04.mp4
M1L05.mp4
M2L11.mp4
M2L12.mp4
M2L13.mp4
M2L14.mp4
M2L15.mp4
M3L21.mp4
M3L22.mp4
M3L23.mp4
M3L24.mp4
M3L25.mp4

S. Baskar
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines


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

2015-10-28 Thread Shakthi Kannan
Hi,

--- On Wed, Oct 28, 2015 at 2:55 PM, Baskar Selvaraj
 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?

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