View Single Post
  #2   (View Single Post)  
Old 12th December 2008
sverreh's Avatar
sverreh sverreh is offline
Real Name: Sverre Hval
Port Guard
 
Join Date: Apr 2008
Location: Norway
Posts: 36
Default

WOW, that was an impressing demo of mastering regexp I think I would have used hours to do that!
As usual your post is very clear, easy to follow (even for amateurs like me) and straight to the point.

To rename a lot of files, I usually utilize vils.
Code:
sverre % ls
latest-pkg              latest-pkg-erlangen     latest-pkg-plig
latest-pkg-calyx        latest-pkg-esat         latest-pkg-stacken
sverre %  vils
      1 0001 latest-pkg
      2 0002 latest-pkg-calyx
      3 0003 latest-pkg-erlangen
      4 0004 latest-pkg-esat
      5 0005 latest-pkg-plig
      6 0006 latest-pkg-stacken
~
Then, in vils give the command
Code:
:%s/-/_/
which gives
Code:
       1 0001 latest_pkg
       2 0002 latest_pkg-calyx
       3 0003 latest_pkg-erlangen
       4 0004 latest_pkg-esat
       5 0005 latest_pkg-plig
       6 0006 latest_pkg-stacken
~
Then exit vils in the standard vi way:
Code:
:wq 
sverre % ls
latest_pkg              latest_pkg-erlangen     latest_pkg-plig
latest_pkg-calyx        latest_pkg-esat         latest_pkg-stacken
sverre %
This is probably faster if you have the files in only a few directories, but I in your case with many directories I would think your sed-script is more suitable. Not to mention how fun it is to experiment with regular expressions!

Last edited by sverreh; 12th December 2008 at 12:42 PM.
Reply With Quote