Date: Wed, 31 Jul 2002 20:50:24 -0400 (EDT) From: John Bleichert <syborg@stny.rr.com> To: freebsd-questions@FreeBSD.ORG Subject: Re: files to files with .txt Message-ID: <Pine.LNX.4.44.0207312049450.4091-100000@janeway.vonbek.dhs.org> In-Reply-To: <Pine.LNX.4.44.0207311856570.4091-100000@janeway.vonbek.dhs.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Soumebody else provided a nice /bin/sh one-liner:
for I in * ; do mv $I $I.txt ; done
On Wed, 31 Jul 2002, John Bleichert wrote:
>
> Here's a small, entry-level perl script:
>
> #!/usr/bin/perl
>
> @listing = `ls`; # in dir with the files
>
> foreach $i ( @listing )
> {
> chomp($i);
> system("mv $i $i.txt");
> }
>
> You'll need to modify it so it doesn't rename itself, if run from the same
> directory. All those 'system' calls may be expensive, though, this may be
> a call for sed/awk ;-)
>
> On Wed, 31 Jul 2002, Maciej Szewczyk wrote:
>
> > Date: Wed, 31 Jul 2002 23:02:56 +0200
> > From: Maciej Szewczyk <rodion@pirx.9lo.lublin.pl>
> > To: questions@FreeBSD.ORG
> > Subject: files to files with .txt
> >
> > 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
> >
> > How can I do that.
> > Tahnks for help.
> >
> > Maciej Szewczyk
> >
> > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > with "unsubscribe freebsd-questions" in the body of the message
> >
>
> /*
> * John Bleichert
> * syborg@stny.rr.com
> * http://vonbek.dhs.org/latest.jpg
> */
>
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
>
/*
* John Bleichert
* syborg@stny.rr.com
* http://vonbek.dhs.org/latest.jpg
*/
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.44.0207312049450.4091-100000>
