Looks like you are running Windows based on Outlook in header.  So something
like this ought to do it:

============ BASIC ============
#!perl.exe -w

@files = `dir /s /b C:\\*.expect`;
chomp @files;

for (@files) {
        s#\\#\\\\#g;
        $newfile = $_ . ".bak";
        `move \"$_\" \"$newfile\"`;
}

__END__

========= EXTRAVAGANT =========
#!perl.exe -w

print "Finding .expect files...\n\n";

@files = `dir /s /b C:\\*.expect`; /s = subdirs, /b = bare
chomp @files;

for (@files) {
        s#\\#\\\\#g;
        $newfile = $_ . ".bak";
        $msg .= "$_ => $newfile\n";
        print "$_ => $newfile\n";
        # Need escaped quotes in shell for dirs with spaces
        `move \"$_\" \"$newfile\"`;
}

if (! @files) {
        $msg .= "None found\n"
}

$date = `date /T`; chop $date;
$time = `time /T`; chop $time;

$msgwrite = $date . $time . "\n=========================\n";
$msgwrite .= "$msg\n\n";

open (LOG, ">> log.txt"); print LOG $msgwrite; close LOG;

__END__

========= OUTPUT to log ==========

Fri 12/21/2001  1:14a
=========================
C:\\test.expect => C:\\test.expect.bak
C:\\My Documents\\test.expect => C:\\My Documents\\test.expect.bak

Sorry to sort of do the whole thing but it's the endorphin factor.  Leaving it
to you to get rid of the double backslashes in screen print and log.

Cheers,

/g
Let's send a man to Mars with Perl.

[Shortest day of the year today, thank God it's over].

> -----Original Message-----
> From: krish [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 12:08 AM
> To: [EMAIL PROTECTED]
> Subject: Taking Backup of some files in a directory structure
>
>
> Hi,
>
> I am a beginner in Perl and have a very trivial query. I have some .expect
> files in my directory structure which are spread all throughout. I want to
> convert these files (only expect files) to .expect.bak.  Please let me know
> as to how this can be done using Perl script. Even pointers to shell
> scripting will help.
> Thanks
> K.Srinivas


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to