commit 348b33cd004a3a36b43fa8202aed65c68bcdaeb9
parent 7b3c7d280840d232df60541e1d5be3a53f4101d0
Author: René Wagner <rwagner@rw-net.de>
Date: Tue, 5 May 2020 21:55:48 +0200
WIP: prepare for config loading
Diffstat:
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/art_file_mover.pl b/art_file_mover.pl
@@ -12,6 +12,7 @@ use File::Copy;
use File::Find;
use File::Find::Rule;
use File::Spec::Functions;
+use File::HomeDir;
use Getopt::Std;
$Getopt::Std::STANDARD_HELP_VERSION = 'true';
@@ -19,13 +20,18 @@ $Getopt::Std::STANDARD_HELP_VERSION = 'true';
my $VERSION = '0.41';
my $PROGRAM = 'Art File Mover';
+my $configfile = catfile(File::HomeDir->my_home, '.art_file_mover.conf');
+
# read commandline switches
our $opt_l = 0;
our $opt_r = 'DNG';
our $opt_f = 'JPEG';
our $opt_c = 'jpe{0,1}g';
+our $opt_s = 0;
+
+getconfig($configfile);
-getopts('lr:f:c:') or die "Invalid parameters provided! See 'art_file_mover.pl --help' for more details.";
+getopts('slr: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
@@ -38,6 +44,8 @@ foreach my $arg ( @ARGV )
if ($destination_dir eq getcwd) { $opt_l = 1; }
+if ( $opt_s ) { writeconfig($configfile); }
+
move_files($destination_dir);
exit 0;
@@ -100,6 +108,16 @@ sub move_files
say "\r\nfound $move_counter files.";
}
+sub getconfig
+{
+ my ( $config_filename ) = @_;
+}
+
+sub writeconfig
+{
+ my ( $config_filename ) = @_;
+}
+
sub main::VERSION_MESSAGE()
{
say $PROGRAM . ' - version ' . $VERSION;
@@ -116,9 +134,10 @@ sub main::HELP_MESSAGE
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 ' -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 ' -s : safe current options (-r, -f, -c only) to user profile. If present the saved values are applied automatically.';
say ' --help : show this help';
}