Searching specific path

General questions about using WildEdit

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
batsys
Posts: 2
Joined: Sat Apr 19, 2008 1:15 pm
Location: UK
Contact:

Searching specific path

Post by batsys »

Is it possible in WildEdit to search files that lay on a specific path or path fragment?

Here's the problem, our beloved IT department has changed our CVS server's name and I need to update all references to the CVS instance. These are kept in a file called 'Root' that lives in a folder called 'CVS' in all the directories that are managed by CVS.

The actual replace is a simple edit that swaps "sunserv09" for "cvs" in the file 'Root'. Is it possible to get WildEdit to only look for

CVS\Root

i.e., files called 'Root' that are in a directory called 'CVS' and ignore any file called 'Root' in any other parent directory?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I don't believe this is possible in WildEdit.

But if you use CVS, you should have no trouble with a scripting language, for example, Perl:

Code: Select all

use File::Find ;

my $ext = '.orig' ;

find \&doIt, '.' ;

sub doIt ()
{
  if ( $File::Find::dir =~ m|/CVS$| && $_ eq 'Root' )
  {
    print "$File::Find::name\n" ;

    my $new =  $_        ;
    my $bup = "$new$ext" ;

    rename $new, $bup or die "Can't back up $File::Find::name: $!\n" ;

    open BUP, "<$bup" or die "Can't open $File::Find::name$ext: $!\n" ;
    open NEW, ">$new" or die "Can't open $File::Find::name: $!\n" ;

    for my $line ( <BUP> )
    {
      $line =~ s/cvs/sunserv09/ ;
      print NEW $line ;
    }

    close NEW ;
    close BUP ;
  }
}
batsys
Posts: 2
Joined: Sat Apr 19, 2008 1:15 pm
Location: UK
Contact:

Thanks

Post by batsys »

Thanks for the input Ben. In the end I wrote a Python script to do much the same sort of thing.
Post Reply