Skip site navigation (1)Skip section navigation (2)
Date:      08 Jan 2003 16:23:03 +0000
From:      Ian Watkinson <ian.watkinson@ehsbrann.com>
To:        "BigBrother (BigB3)" <bigbrother@bonbon.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Renaming files with spaces in the name to files without spaces..
Message-ID:  <1042042983.9701.19.camel@pan.ehsbrann.com>
In-Reply-To: <20030108175539.W65616@bigb3server.bbcluster.gr>
References:  <20030108175539.W65616@bigb3server.bbcluster.gr>

next in thread | previous in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1042042983.9701.19.camel>