Skip to content

Instantly share code, notes, and snippets.

@yaasita
Created April 1, 2019 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaasita/e94024a44ae9c1f9359a9ad715566740 to your computer and use it in GitHub Desktop.
Save yaasita/e94024a44ae9c1f9359a9ad715566740 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;
use File::Find;
use Getopt::Long;
my $base = '';
my $target = '';
GetOptions('base=s' => \$base, 'target=s' => \$target);
if ($base eq '' or $target eq ''){
say "usage: $0 --base /path/dir --target /path/dir/media/";
exit 1;
}
$base .= "/" if $base !~ /\/$/;
$target .= "/" if $target !~ /\/$/;
sub list {
my $file_fullpath = $_;
my $file_size = -s $file_fullpath;
if ($file_size
and -f $file_fullpath
and ! -l $file_fullpath){
my $file_print = $file_fullpath;
$file_print =~ s/$base//;
say "$file_print\t$file_size";
}
}
find({wanted => \&list, no_chdir => 1}, $target);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment