summaryrefslogtreecommitdiffabout
path: root/rfile
Side-by-side diff
Diffstat (limited to 'rfile') (more/less context) (ignore whitespace changes)
-rwxr-xr-xrfile83
1 files changed, 83 insertions, 0 deletions
diff --git a/rfile b/rfile
new file mode 100755
index 0000000..82ed5c2
--- a/dev/null
+++ b/rfile
@@ -0,0 +1,83 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use diagnostics;
+
+use Getopt::Long;
+
+my @dir = ();
+my $ext = q{};
+my $verbose = 3;
+my %cfgOpts = ('use color' => 1);
+my $quiet = 0;
+
+my $get_opt = GetOptions (
+ "dir|d=s" => \@dir,
+ "ext|e=s" => \$ext,
+ "v+" => \$verbose,
+ );
+
+require "modules/renrot_dir.pm";
+require "modules/renrot_msg.pm";
+
+my $msg = new msg($cfgOpts{'use color'},$quiet,$verbose);
+
+if (not $ext) {
+ $msg->Fatal("You have define EXT!\n");
+ exit 1;
+} elsif ($ext !~ m/^\..*$/) {
+ $msg->Dbg(4, "ext:\t",$ext,"\n");
+ $ext = "." . $ext;
+}
+
+if (not @dir) {
+ @dir = (".");
+}
+
+use File::Find;
+use File::Basename;
+
+my %dir_st = ();
+
+######################################################################
+# Usage : pars_files
+# Purpose : to prepare hash of objects with file details
+# Returns : none
+# Parameters : none
+# Throws : no exceptions
+# Comments : it use global variables to fill
+# See Also : package renrot_dir
+sub pars_files {
+ my $EXT = (fileparse($File::Find::name, $ext))[2];
+ if ( -f $File::Find::name and $EXT eq $ext) {
+ if (not $dir_st{$File::Find::dir}) {
+ $dir_st{$File::Find::dir} = new renrot_dir();
+ $dir_st{$File::Find::dir}->{dir} = $File::Find::dir;
+ $dir_st{$File::Find::dir}->{ext} = $EXT;
+ }
+ push @{$dir_st{$File::Find::dir}->{files}}, basename($_,$EXT);
+ }
+}
+
+find \&pars_files, @dir;
+
+my @files = ();
+foreach my $dir (sort keys %dir_st) {
+ $msg->Proc("\nDIR: ", $dir, "\n");
+ for (my $i = 0,@files = @{$dir_st{$dir}->{files}}; $i < scalar @files; $i++) {
+ $msg->Proc("\tFILE: ", $files[$i], "\t\tEXT: ",
+ $dir_st{$dir}->{ext}, "\t FULLNAME: ",
+ $dir_st{$dir}->file_name($files[$i],$dir_st{$dir}->{ext}),"\n");
+ #if ( $i == 0 ) {
+ # chdir $dir_st{$dir}->{dir};
+ #}
+ #open(FH, $dir_st{$dir}->file_name($files[$i],$dir_st{$dir}->{ext}))
+# or die "Can't open ",$dir_st{$dir}->file_name($files[$i],$dir_st{$dir}->{ext}),": $!";
+ #while (<FH>) {
+ # $msg->Proc( $_,"\n");
+ #}
+ #close(FH);
+ }
+ undef @files;
+}

Return to:

Send suggestions and report system problems to the System administrator.