Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thanks o Wise Monks. I will try the suggestions. Here is my whole script so you can see how I am using the command. I should have put it here earlier
More then just writing a script to find duplicates, I want to refresh my perl scripts on which I have lost touch over the last few years.

use strict; use IO::File; use Digest::MD5 qw(md5); my ($aLen, $i, $j, $tFile, $sFile); my (@sDir,@tDir); my ($cFile, $ex1, $ex2); my ($cFile2, $chk1, $chk2); my ($fs1, $fs2); my($par1,$par2,$par3,$par4) = ($ARGV[0],$ARGV[1],$ARGV[2],$ARGV[3]) ; + # Expects a slash at the end if directory # par1 is the directory to Check # par2 is directory to check against # Exact dups are placed in ncn_cmp.bat to delete from first folder # Differences in ncn_diff.txt as either missing or different <br> $par1 = $par1 || ".\\"; $ex1 = $par2 || ".err"; $ex2 = $par3 || ".fmx"; $par4 = $par4 || "NCN"; $chk1 = "Apple"; open (OUT, ">ncn_cmp.bat"); open (DF, ">ncn_diff.txt"); open (SM, ">ncn_same.txt"); $tFile="XXX"; if (-d $par1) { opendir D1, $par1; #@tDir=sort (readdir D1); #@sDir=sort {-s $a <=> -s $b } @tDir; @sDir=sort {-s $a <=> -s $b } (readdir D1); $aLen = @sDir; for ($j=0;$j<$aLen;$j++){ next if !(-f $par1 . "\\" .$sDir[$j]); next if $sDir[$j] eq "ncn_cmp.bat"; next if $sDir[$j] eq "ncn_diff.txt"; next if $sDir[$j] eq "ncn_same.txt"; if ($par1 =~ s/\\$//g){ $sFile = $par1 . $sDir[$j]; } else { $sFile = $par1 . "\\" . $sDir[$j]; } #$sFile = $par1 . "\\" . $sDir[$j]; if ($tFile eq "XXX") { $tFile = $sFile; next; } $fs1 = -s $sFile; $fs2 = -s $tFile; if ($fs1 eq $fs2) { open(TST, "<", $tFile); $chk2 = md5(<TST>); close(TST); open(TST, "<", $sFile); $chk1 = md5(<TST>); close(TST); } else { # print $sFile . " size " . $fs1 . "\n"; # print $tFile . " size " . $fs2 . "\n"; $chk2 = "DIF"; } if ($chk1 eq $chk2) { print OUT "del \"" . $sFile . "\"\n"; print SM "echo N | comp " . $tFile . " " . $sFile . "\n"; } else { if ($chk2 eq "NCN") { print DF $tFile . " Not Found\n"; } else {<br> print DF $tFile . " and " . $sFile . " different\n"; } } $chk1 = "ABC"; $chk2 = "DEF"; $tFile = $sFile; } } print OUT "del ncn_diff.txt\n"; print OUT "del ncn_same.txt\n"; print OUT "del ncn_cmp.bat\n"; close(OUT); close(DF); close(SM);

In reply to Re^2: Sort directory by file size by nnigam1
in thread Sort directory by file size by nnigam1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (1)
    As of 2021-05-10 06:46 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Perl 7 will be out ...





      Results (104 votes). Check out past polls.

      Notices?