Date: Fri, 2 Aug 2002 13:58:20 +1000 From: "Pietralla, Siegfried P" <siegfried.pietralla@eds.com> To: "'John Mills'" <john.m.mills@alum.mit.edu>, Maciej Szewczyk <rodion@pirx.9lo.lublin.pl> Cc: questions@FreeBSD.ORG Subject: RE: files to files with .txt Message-ID: <16649A8D5C73D51183B80008C728EEB7CC0AD5@AUSYM103>
next in thread | raw e-mail | index | archive | help
> -----Original Message----- > From: John Mills [mailto:jmmills@telocity.com] > Sent: Friday, 2 August 2002 12:07 > To: Maciej Szewczyk > Cc: questions@FreeBSD.ORG > Subject: Re: files to files with .txt > > > Hello - > > On Wed, 31 Jul 2002, Maciej Szewczyk wrote: > > > Hi, > > I have about 1000 files. > > ls -1 > > 1 > > 2 . . . > > And now I must have 1000 files with .txt -> > > ls -1 > > 1.txt > > 2.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 i've found that the easiest ( and least typing ) way to check stuff like this is to : for i in * ; do echo mv $i $i.txt ; done to see what you're going to get, then just append " | sh " ; for i in * ; do echo mv $i $i.txt ; done | sh to execute it. regards, siegfried. 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?16649A8D5C73D51183B80008C728EEB7CC0AD5>