App-MarkFiles
view release on metacpan or search on metacpan
bin/mark-cp view on Meta::CPAN
use App::MarkFiles qw(each_path);
use File::Basename;
use File::Copy;
use File::Spec;
use Getopt::Long;
each_path(sub {
my ($path) = @_;
unless (-e $path) {
say "No such file: $path";
return;
}
my ($source_basename, $source_path) = fileparse($path);
my $target = File::Spec->catfile('.', $source_basename);
if (-e $target) {
say "Warning: $path will overwrite $target";
# See mark-mv for some discussion of what happens if target exists.
}
if (copy($path, './')) {
say "Copied: $path";
} else {
say "Copy failed: $!"
}
});
bin/mark-ls view on Meta::CPAN
use Getopt::Long;
use Pod::Usage;
GetOptions(
# 'config=s' => \$config_file,
help => sub { pod2usage(0) },
) or pod2usage(2);
each_path(sub {
my ($path) = @_;
say $path;
});
bin/mark-mv view on Meta::CPAN
use File::Copy;
use File::Spec;
use Getopt::Long;
my @unmark;
each_path(sub {
my ($path) = @_;
unless (-e $path) {
say "No such file: " . $path;
return;
}
my ($source_basename, $source_path) = fileparse($path);
my $target = File::Spec->catfile('.', $source_basename);
if (-e $target) {
say "Warning: $path will overwrite $target";
# So here's the question. What do we do if the target exists?
#
# There are a couple of cases here:
#
# 1. Our mark list contains a file of the same name as something already in
# the destination directory.
#
# 2. Our mark list contains the same filename more than once.
#
bin/mark-mv view on Meta::CPAN
# unexpected outcomes.
#
# We could refuse to operate unless a "rename duplicates" option is
# invoked, or just interactively solve each collision. This seems most
# pressing for mark-mv, since it could easily result in data loss by
# cascading a set of moves where you wind up with just one source file
# left anywhere.
}
if (move($path, $target)) {
say "Moved: $path";
push @unmark, $path;
} else {
say "Move failed: $!"
}
});
remove(@unmark);
( run in 1.371 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )