Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Aug 2002 22:06:54 -0400 (EDT)
From:      John Mills <jmmills@telocity.com>
To:        Maciej Szewczyk <rodion@pirx.9lo.lublin.pl>
Cc:        questions@FreeBSD.ORG
Subject:   Re: files to files with .txt
Message-ID:  <Pine.LNX.4.21.0208012201000.5158-100000@otter.mills-atl.com>
In-Reply-To: <20020731230256.A19666@pirx.9lo.lublin.pl>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello -

On Wed, 31 Jul 2002, Maciej Szewczyk wrote:

> Hi,
> I have about 1000 files.
> ls -1
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> ...
> ...
> 998
> 999
> 1000
> And now I must have 1000 files with .txt ->
> ls -1
> 1.txt
> 2.txt
> 3.txt
> ...
> ...
> 998.txt
> 999.txt
> 1000.txt

DISCLAIMER - This is on-the-fly - you'll probably need to tune it and/or
correct it. Of course you could just write it as a [bash] script. Get the
form right _without_ the 'mv' line, and if possible save a copy of your
directory before you munge the real files.

$ ls > ../1000_files
$ for FILENAME in `cat ../1000_files`
 > do
 >  echo "Renaming $FILENAME to $FILENAME.txt"
 >  mv $FILENAME $FILENAME.txt
 > done
 Renaming 001 to 001.txt
 ....

$

 - John Mills


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?Pine.LNX.4.21.0208012201000.5158-100000>