On Wed, 2003-01-08 at 16:01, BigBrother (BigB3) wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> Sorry for this OT but I am trying for some hours to achieve a massive
> rename of files using a simple script and I have not success yet. I want
> to rename files like
> 
> "RESULTS OF JAN 01 2002.txt "
> 
> to
> 
> "RESULTS_OF_JAN_01_2002.txt"
> 
> i.e. all the spaces, being substituted by '_', and the last space being
> completely removed [yes it has a space after the suffix]
> I tried to experiment with sed/awk and creating a sample sh script with
> for i in 'ls' ....
> 
> but the i takes values of 'RESULTS' 'OF' 'JAN'. This means that it doesnt
> take the full filename as value, but parts of the filenames.
> 
> 
> Can u please suggest an easy way to implement the massive rename?
> 
> 
> 
> 
> Thank you very very much in advance!!!!
> 
Possible to do as 1 line in perl, better done as 5 line readable script

look up the perl command chomp

Hope that points you in the right direction, alternatively google for
regex, and look specifically for how to look for something ending in
something.

http://www.perldoc.com/perl5.6.1/pod/perlre.html

Has the answers for you in perl

-- 

Ian Watkinson
EHS Brann
Systems Administrator


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to