Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2. use File::Basename;
  3.  
  4. $filepath = $ARGV[0];
  5. if(!$filepath) { $filepath = "." }
  6. @files = <$filepath/*>;
  7. foreach(@files) {
  8.    if(! -d $_) {
  9.       if(/\.flv$/) {
  10.          $date = $_;
  11.          $date = substr($date, 0, 8);
  12.          push(@list, $date);
  13.       }
  14.    } else {
  15.       $dir = basename($_);
  16.       @a = <$filepath/*$dir*.flv>;
  17.       if(@a) {
  18.          $a = `mv $filepath/*$dir*.flv $_/`;
  19.       }
  20.    }
  21. }
  22.  
  23. %seen = ();
  24. @uniq = ();
  25. foreach $item (@list) {
  26.    push(@uniq, $item) unless $seen{$item}++;
  27. }
  28.  
  29. foreach(@uniq) {
  30.    $dir = "$filepath/$_";
  31.    if(mkdir($dir)) {
  32.       $a = `mv $filepath/*$_*.flv $dir/`;
  33.    }
  34. }