🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #74234

Re: Renaming a newsgroup

#74234
From: Jeffrey M. Vinocur
Date: Tue, 12 Sep 2006 14:25
49 lines
3159 bytes
In article <b5fNg.106750$5i3.29042@bgtnsc04-news.ops.worldnet.att.net>,
John F. Morse <xanadu.bbs@invalid.net> wrote:
>
>perl renamer.pl [...]

Incidentally, if you `chmod a+x renamer.pl` (and make sure the
first line of the script points to where Perl actually is on your
system), you can run this without needing the "perl" in front.


>I was getting an "Argument list too long" failure. [...]
>
>I'll let it set until I hear from you, just in case you want to try a 
>Perl script modification, and want me to test it.

Oh, I probably ought to make the script smart enough to recurse
into directories itself, since people probably almost always run
it on a whole directory of files.  But I probably won't bother,
because...

This is a common problem of the shell's argument processing, that
manifests with many programs that take a very long list of files
as input.  The workaround (assuming the program can be run on
subsets of the files without the details/orders of the arguments
being important) is to do something like this:

    find . -type f -print | xargs renamer.pl oldgroup newgroup

which will run renamer.pl repeatedly on different batches of
input files.  The "." after find is the path to start looking in
(here, the current directory), -type f means only true files (not
directories etc), and -print is usually not necessary but tells
find to output the list of files it located, one per line.

You should know that the above command won't work with special
characters (including white space) in filenames.  That's not a
problem here, but for future reference, the safer invocation is:

    find . -type f -print0 | xargs -0 renamer.pl oldgroup newgroup

or whatever.  That uses a special delimiter so xargs doesn't have
to guess how to separate out the filenames.  However, not all
versions of find/xargs know how to do this, so you can't rely on
it always being available.


-- 
Jeffrey M. Vinocur
jeff@litech.org
Technical Details
Message-ID: <ee6g0n$k08$1@puck.litech.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!news.litech.org!not-for-mail
References: <AiTMg.17827$QM6.1566@bgtnsc05-news.ops.worldnet.att.net> <ee3bcp$sqa$1@puck.litech.org> <OwbNg.22657$QM6.20750@bgtnsc05-news.ops.worldnet.att.net> <b5fNg.106750$5i3.29042@bgtnsc04-news.ops.worldnet.att.net>

Show Full Headers
Complete Article Headers
Message-ID: <ee6g0n$k08$1@puck.litech.org>
Subject: Re: Renaming a newsgroup
Date: Tue, 12 Sep 2006 14:25:27 +0000
From: jeff@litech.org (Jeffrey M. Vinocur)
References: <AiTMg.17827$QM6.1566@bgtnsc05-news.ops.worldnet.att.net> <ee3bcp$sqa$1@puck.litech.org> <OwbNg.22657$QM6.20750@bgtnsc05-news.ops.worldnet.att.net> <b5fNg.106750$5i3.29042@bgtnsc04-news.ops.worldnet.att.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!news.litech.org!not-for-mail
Newsgroups: news.software.nntp
Organization: Litech Systems Design
Lines: 49
Sender: jeff@litech.org
NNTP-Posting-Host: puck.litech.org
X-Trace: puck.litech.org 1158071127 20488 66.218.0.75 (12 Sep 2006 14:25:27
 GMT)
X-Complaints-To: usenet@litech.org
NNTP-Posting-Date: Tue, 12 Sep 2006 14:25:27 +0000 (UTC)
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: jeff@litech.org (Jeffrey M. Vinocur)