commit bb1d52906f3530accc153438021efcec31d72f24
parent d5146f66688dc4165f5d81093e0e67cb2946bb1e
Author: René Wagner <rwagner@rw-net.de>
Date: Sun, 13 Sep 2020 13:59:03 +0200
jd: allow custom jpeg extension
Diffstat:
M | afm.pl | | | 36 | ++++++++++++++++++------------------ |
M | jd.pl | | | 10 | +++++++--- |
2 files changed, 25 insertions(+), 21 deletions(-)
diff --git a/afm.pl b/afm.pl
@@ -23,12 +23,12 @@ my $configfile = catfile(File::HomeDir->my_home, '.afm.conf');
our $opt_l = 0;
our $opt_r = 'DNG';
our $opt_f = 'JPEG';
-our $opt_c = 'jpe{0,1}g';
+our $opt_e = 'jpe{0,1}g';
our $opt_s = 0;
getconfig();
-getopts('slr:f:c:') or die "Invalid parameters provided! See 'afm.pl --help' for more details.";
+getopts('slr:f:e:') or die "Invalid parameters provided! See 'afm.pl --help' for more details.";
# read remaining commandline args für destination dir
# last dir will win
@@ -55,7 +55,7 @@ sub move_files
say "destination dir : $destination_dir";
say "raw file ext : $opt_r";
say "output file dir : $opt_f";
- say "output file ext : $opt_c";
+ say "output file ext : $opt_e";
say 'action : '. ($opt_l ? 'list only' : 'move');
say '';
my $converted_destination_dir = catfile($destination_dir, $opt_f);
@@ -67,7 +67,7 @@ sub move_files
}
# find all jpegs in current dir
- my @files = File::Find::Rule->file()->name( qr/\.$opt_c$/i )->maxdepth(1)->in( catfile(getcwd, $opt_f) );
+ my @files = File::Find::Rule->file()->name( qr/\.$opt_e$/i )->maxdepth(1)->in( catfile(getcwd, $opt_f) );
foreach my $converted_file ( @files )
{
@@ -92,7 +92,7 @@ sub move_files
move($rawarp_file, catfile($destination_dir, basename($rawarp_file)));
if ( move($converted_file, catfile($converted_destination_dir, basename($converted_file))) &&
- move($raw_file, catfile($destination_dir, basename($raw_file))) )
+ move($raw_file, catfile($destination_dir, basename($raw_file)) ))
{
print 'moved.';
}
@@ -116,7 +116,7 @@ sub writeconfig
{
open(my $filehandle, '>', $configfile) or die "Could not open file '$configfile': $!";
say $filehandle '$opt_f="'. $opt_f .'";';
- say $filehandle '$opt_c="'. $opt_c .'";';
+ say $filehandle '$opt_e="'. $opt_e .'";';
say $filehandle '$opt_r="'. $opt_r .'";';
close $filehandle;
}
@@ -131,17 +131,17 @@ sub main::VERSION_MESSAGE()
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 '';
- say 'usage: afm(.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 '';
+ say 'Find all by ART converted files in the current folder and their corresponding RAWs and move them to specified directory.';
+ say '';
+ say 'usage: afm(.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 ' -e <ext> : override the converted file extenion (case-insensitive), defaults to "jp(e)g"';
say ' Perl-compatible regular expressions allowed';
- say ' -s : safe current options (-r, -f, -c only) to user profile. If present the saved values are applied automatically.';
- say ' --help : show this help';
+ say ' -s : safe current options (-r, -f, -e only) to user profile. If present the saved values are applied automatically.';
+ say ' --help : show this help';
}
diff --git a/jd.pl b/jd.pl
@@ -19,8 +19,9 @@ my $PROGRAM = 'JpegDivider';
# read commandline switches
our $opt_l = 0;
our $opt_f = 'JPEG';
+our $opt_e = 'jpe{0,1}g';
-getopts('lf:') or die "Invalid parameters provided! See 'jd.pl --help' for more details.";
+getopts('lf:e:') or die "Invalid parameters provided! See 'jd.pl --help' for more details.";
# read remaining commandline args
# last dir will win
@@ -42,7 +43,8 @@ sub move_files
say "working directory: $dir";
say 'action : '. (!$opt_l ? 'move' : 'list only');
say "subfolder : $opt_f";
- say '';
+ say "file ext : $opt_e";
+ say '';
my $destination_dir = catdir($dir, $opt_f);
if ( !$opt_l && ! -d $destination_dir )
@@ -50,7 +52,7 @@ sub move_files
mkdir $destination_dir or die "Could not create destination dir $_ : $!";
}
- my @files = File::Find::Rule->file()->name( qr/\.jpe{0,1}g$/i )->maxdepth(1)->in( $dir );
+ my @files = File::Find::Rule->file()->name( qr/\.$opt_e$/i )->maxdepth(1)->in( $dir );
foreach my $file ( @files )
{
@@ -91,5 +93,7 @@ sub main::HELP_MESSAGE
say 'options:';
say ' -l : list-only mode - does not move files but only lists which files would be moved';
say ' -f <folder> : use the given subfolder instead of "JPEG"';
+ say ' -e <ext> : override the converted file extenion (case-insensitive), defaults to "jp(e)g"';
+ say ' Perl-compatible regular expressions allowed';
say ' --help : show this help';
}