HighDots Forums  

Mass Changes

alt.html.tags alt.html.tags


Discuss Mass Changes in the alt.html.tags forum.



Reply
 
Thread Tools Display Modes
  #31  
Old   
Bill Clark
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 11:50 AM






Matt Probert wrote:

Quote:
BTW, sorry to get back on topic, but I do have a simple command line
application that takes three parameters: file spec, search string,
replacement string and does an automatic replacement on all matching
files in the current directory.
I do too, except it's for OS/2 <g>

Quote:
If some one has a freeware site, they are welcome to a copy to make
available.
If you would send a copy to twentytwentyhindsight at usa dot net
(substitute digits in the obvious place) I will make it available...

--
-bc-
Sexy Senior Citizen

Support your local retailer



Reply With Quote
  #32  
Old   
Els
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 11:51 AM






Matt Probert wrote:

Quote:
BTW, sorry to get back on topic, but ...
Doesn't that just define a.w.w. completely? ;-)

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -



Reply With Quote
  #33  
Old   
Els
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 11:56 AM



Matt Probert wrote:

Quote:
Clearer? To the illiterate, perhaps, for if one understands the
meaning of the word, then it is certainly not clearer!

You caught me.. I hang out with the illiterate too much. I
am used to make them understand me :-(

I should like to apologise to you Els, and make it clear that I did
not intend to imply that Els or any other particular indiviudual is
illiterate. Sorry if I caused you any upset.
No need for apologies, Matt, it takes a lot more than that
to upset me :-)

(can't speak for anyone else though)

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -



Reply With Quote
  #34  
Old   
Bill Clark
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 12:05 PM



Matt Probert wrote:

Quote:
If some one has a freeware site, they are welcome to a copy to make
available.
Oops! I misread your message as free site as opposed to freeware...

--
-bc-
Sexy Senior Citizen

Support your local retailer



Reply With Quote
  #35  
Old   
Matt Probert
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 12:46 PM



On Tue, 08 Jun 2004 16:39:18 GMT comments (AT) probertencyclopaedia (DOT) com
(Matt Probert) broke off from drinking a cup of tea at The Probert
Encyclopaedia to write:

Quote:
On the other hand, something similar could be written in a few lines
of Perl and posted here. Okay last to post the (quick and dirty) Perl
solution is a sissy! <g

Pkay, here's a quick and dirty one. I repeat it's QUICK AND DIRTY and
not a showcase for the most elegant Perl programming ever! Ok? No
flames please!

-- Begin

#!/usr/bin/perl

# A quick and dirty global search and replace program written in Perl
# Supplied as is without warranty
# Usage is 'perl gsr.pl <file spec> <find> <replace>

# There is plenty of scope for improvements, not least of which
# is modifying the program to span line breaks!

# Note:
# A bug in Windows means that file names in lower case, which
# conform to the 8.3 naming convention will be converted to
# uppercase by this program. eg: myfile.htm will be renamed
# MYFILE.HTM

die "Usage is $0 <file spec> <search> <replace>\n" if $#ARGV != 2;

# Extract file names matching ARGV[0] into a list
@fnames=glob($ARGV[0]);

foreach $file (@fnames)
{
open(FILE, $file);
open(TEMP,">temp");
while (<FILE>)
{
# Replace all occurences of the second command line
argument
# with the second within the current line in the file

$_ =~ s/$ARGV[1]/$ARGV[2]/gi;

print TEMP "$_";
}
close(FILE);
close(TEMP);
rename(temp,$file);
}

-- end


--
Free searchable encyclopaedia content for your web site:
http://www.probertencyclopaedia.com/xsearch.htm


Reply With Quote
  #36  
Old   
Charles Sweeney
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 01:54 PM



"Matt Probert" <comments (AT) probertencyclopaedia (DOT) com> wrote


Quote:
Pkay, here's a quick and dirty one. I repeat it's QUICK AND DIRTY and
not a showcase for the most elegant Perl programming ever! Ok? No
flames please!
Here's a simpler one:

-- begin

#!/usr/bin/perl

find(this)

and_replace_it_with(this)

-- end

UNTESTED I hasten to add!
--
Charles Sweeney
www.CharlesSweeney.com




Reply With Quote
  #37  
Old   
Toby A Inkster
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 03:24 PM



Matt Probert wrote:

Quote:
On the other hand, something similar could be written in a few lines
of Perl and posted here. Okay last to post the (quick and dirty) Perl
solution is a sissy! <g
Is two lines (excluding shebang) too many? I can do it in one if I'm
allowed to change the order of the arguments to STRING, REPLACEMENT,
FILESPEC.

#!/usr/bin/perl
$a = shift @ARGV;
system("sed -i 's/" . shift @ARGV . '/' . shift @ARGV . "/g' $a");

(Very dirty. Won't work for some STRINGs -- anything that has a special
meaning in a regexp.)

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132



Reply With Quote
  #38  
Old   
Charles Sweeney
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 04:16 PM



"Toby A Inkster" <tobyink (AT) goddamn (DOT) co.uk> wrote


Quote:
Is two lines (excluding shebang) too many? I can do it in one
Crikey, it's like Name That Tune!
--
Charles Sweeney
www.CharlesSweeney.com




Reply With Quote
  #39  
Old   
Toby A Inkster
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 05:23 PM



Toby A Inkster wrote:

Quote:
#!/usr/bin/perl
$a = shift @ARGV;
system("sed -i 's/" . shift @ARGV . '/' . shift @ARGV . "/g' $a");
Dammit! That'll teach me not to test my scripts before posting! Order of
precendence...

#!/usr/bin/perl
$a = shift @ARGV;
system("sed -i 's/" . (shift @ARGV) . '/' . (shift @ARGV) . "/g' $a");

And here's a shorter one...

#!/usr/bin/perl
system("sed -i 's/".$ARGV[++$a].'/'.$ARGV[++$a]."/g' ".$ARGV[$b]);

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132



Reply With Quote
  #40  
Old   
Mark Parnell
 
Posts: n/a

Default Re: Mass Changes - 06-08-2004 , 06:34 PM



On Tue, 08 Jun 2004 13:15:12 GMT, Matt Probert
<comments (AT) probertencyclopaedia (DOT) com> declared in
alt.html,alt.html.tags,alt.www.webmaster:

Quote:
English language, it's richness and complete lack of logic!
^
And its wayward apostrophes! :-D

--
Mark Parnell
http://www.clarkecomputers.com.au


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.