Created
April 1, 2019 07:15
-
-
Save yaasita/e94024a44ae9c1f9359a9ad715566740 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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