art-helpers

simple helper scripts for managing images processed by ART
git clone https://git.clttr.info/art-helpers.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 7b3c7d280840d232df60541e1d5be3a53f4101d0
parent 2bf7f26cbf79b3d4491c7e56f23ee88e0bca8c4a
Author: René Wagner <rwagner@rw-net.de>
Date:   Tue,  5 May 2020 20:23:11 +0200

implement ~rwa/photo-workflow#2: default to move-mode when target folder is given
revamp --help output

Diffstat:
Mart_file_mover.pl | 34++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/art_file_mover.pl b/art_file_mover.pl @@ -16,26 +16,27 @@ use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 'true'; -my $VERSION = '0.4'; +my $VERSION = '0.41'; my $PROGRAM = 'Art File Mover'; # read commandline switches -our $opt_m = 0; +our $opt_l = 0; our $opt_r = 'DNG'; our $opt_f = 'JPEG'; our $opt_c = 'jpe{0,1}g'; -getopts('mr:f:c:') or die "Invalid parameters provided! See 'art_file_mover.pl --help' for more details."; +getopts('lr:f:c:') or die "Invalid parameters provided! See 'art_file_mover.pl --help' for more details."; # read remaining commandline args für destination dir # last dir will win +# fallback to list-only mode when no dir is given my $destination_dir = getcwd; foreach my $arg ( @ARGV ) { $destination_dir = $arg; } -(getcwd ne $destination_dir) or die "target directory is currenty directory!"; +if ($destination_dir eq getcwd) { $opt_l = 1; } move_files($destination_dir); @@ -47,11 +48,11 @@ sub move_files my $move_counter = 0; say "destination dir : $destination_dir"; - say 'action : '. ($opt_m ? 'move' : 'list only'); + say 'action : '. ($opt_l ? 'list only' : 'move'); say ''; my $converted_destination_dir = catfile($destination_dir, $opt_f); - if ( $opt_m && (! -d $destination_dir || ! -d $converted_destination_dir)) + if ( !$opt_l && (! -d $destination_dir || ! -d $converted_destination_dir)) { if (! -d $destination_dir ) { mkdir $destination_dir or die "Could not create destination dir $_ : $!"; } if (! -d $converted_destination_dir ) { mkdir $converted_destination_dir or die "Could not create destination dir $_ : $!"; } @@ -75,7 +76,7 @@ sub move_files { print 'raw-file not found!'; } - elsif ( $opt_m ) + elsif ( !$opt_l ) { # only warn if JPEG or RAW file could not be moved # the processing files *.arp are optional and are fine to be absent @@ -104,19 +105,20 @@ sub main::VERSION_MESSAGE() say $PROGRAM . ' - version ' . $VERSION; say 'published under BSD 3 - Clause License'; say 'Copyright(c) 2019-2020 René Wagner'; - say 'https://git.clttr.info/photo-helpers/'; + say 'https://git.sr.ht/~rwa/photo-helpers'; } sub main::HELP_MESSAGE { say ''; - say 'Find all by ART converted files in the current folder and their corresponding RAWs and move them to specified directory'; + say 'Find all by ART converted files in the current folder and their corresponding RAWs and move them to specified directory.'; say ''; - say 'commandline parameters - should be combined to match your needs:'; - say 'art_file_mover.pl <folder> - list all found files in the current working directory that will eventually be moved'; - say 'art_file_mover.pl -m <folder> - move all converted files and their raws to the given folder'; - say 'art_file_mover.pl -r <rawextension> - override the raw extensions, defaults to "DNG"'; - say 'art_file_mover.pl -f <folder> - override the folder for converted JPEGs, defaults to "JPEG"'; - say 'art_file_mover.pl -c <extension> - override the converted file extenion (case-insensitive), defaults to "jp(e)g"'; - say 'art_file_mover.pl --help - show this help'; + say 'usage: art_file_mover.pl [options] <target folder>'; + say ''; + say 'options:'; + say ' -l : list-only mode - does not move files but only lists which files would be moved'; + say ' -r <raw> : override the raw extensions, defaults to "DNG"'; + say ' -f <folder> : override the folder for converted files, defaults to "JPEG"'; + say ' -c <ext> : override the converted file extenion (case-insensitive), defaults to "jp(e)g"'; + say ' --help : show this help'; }