silkypix-helpers

scripts for managing sidecar files created by SilkyPix Developer Studio
git clone https://git.clttr.info/silkypix-helpers.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit c039a6e8d4d2ef6100c67fef54856d8bcd8a7d4a
parent f8e0e5d16dc964f12ec9511736838ce609be1370
Author: René Wagner <rwa@clttr.info>
Date:   Mon,  1 May 2023 09:03:12 +0200

split Silkypix and ART repos

Diffstat:
MREADME.md | 17+----------------
Dafm | 168-------------------------------------------------------------------------------
Djd | 99-------------------------------------------------------------------------------
3 files changed, 1 insertion(+), 283 deletions(-)

diff --git a/README.md b/README.md @@ -2,7 +2,7 @@ This rather small scripts written in [Perl](https://perl.org) provide useful function for managing (raw and output) files for photographers. ## usage -Simply clone the repo or manually download the scripts from https://src.clttr.info/rwa/photo-helpers/ +Simply clone the repo or manually download the scripts from https://git.sr.ht/~rwa/silkypix-helpers To run the script, open a shell and invoke `perl <script>`, on most systems it should be sufficient to just invoke `script` (after you granted execute-permissions to the script). @@ -20,21 +20,6 @@ Additionally the following perl modules need to be installed: - File::Find::Rule - File::Find -# ART helper scripts -Helper scripts to manage files which where handled by [ART](https://clttr.info/art), the easy-to-use RAW converter forked from RawTherapee. - -## processed file mover -Filename: `afm` - -Moves all already converted raw files and their corresponding jpegs to a given folder. - -# generic scripts - -## JpegDivider -Filename: `jd` - -Moves all jpeg files (suffixes .jpg and .jpeg) in the given folder or the current working directory to the subfolder JPEG (or the given subfolder). - # Silkypix helper scripts Helper scripts to manage the sidecar data files created by [Silkypix Developer Studio](https://clttr.info/silkypix). diff --git a/afm b/afm @@ -1,168 +0,0 @@ -#!/usr/bin/perl -# Copyright(c) René Wagner 2019-2021 -# https://src.clttr.info/rwa/photo-helpers -# published under BSD 3-Clause License - -use Modern::Perl '2019'; -use Cwd; -use File::Basename; -use File::Copy; -use File::Find::Rule; -use File::Spec::Functions; -use File::HomeDir; -use Getopt::Std; - -$Getopt::Std::STANDARD_HELP_VERSION = 'true'; - -my $VERSION = '1.0'; -my $PROGRAM = 'ART File Mover'; - -my $configfile = catfile(File::HomeDir->my_home, '.afm.conf'); - -# read commandline switches -our $opt_l = 0; -our $opt_R = 'DNG'; -our $opt_F = 'JPEG'; -our $opt_E = 'jpe{0,1}g'; -our $opt_C = ''; -our $opt_f = ''; - -getconfig(); - -getopts('lR:F:E:C:f:') or die "Invalid parameters provided! See 'afm --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; -} - -if ($destination_dir eq getcwd) { $opt_l = 1; } - -writeconfig(); - -move_files($destination_dir); - -exit 0; - -sub move_files -{ - my ( $destination_dir ) = @_; - my $move_counter = 0; - - say "destination dir : $destination_dir"; - ($opt_C eq '') or say "copy dir : $opt_C"; - say "file filter : $opt_f"; - say "raw file ext : $opt_R"; - say "output file dir : $opt_F"; - say "output file ext : $opt_E"; - say 'action : '. ($opt_l ? 'list only' : 'move'); - say ''; - my $converted_destination_dir = catfile($destination_dir, $opt_F); - - 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 $_ : $!"; } - } - - # find all jpegs in current dir - my @files = File::Find::Rule->file()->name( qr/\.$opt_E$/i )->name( qr/$opt_f/ )->maxdepth(1)->in( catfile(getcwd, $opt_F) ); - - foreach my $converted_file ( @files ) - { - my ( $filename, $path, $ext ) = fileparse($converted_file, qr/\.[^.]*/); - my $outarp_file = $converted_file. '.out.arp'; - my $raw_file = catfile(dirname($path), $filename .'.'. $opt_R); - my $rawarp_file = $raw_file. '.arp'; - my $rawarp2_file = $filename. '.arp'; - my $xmp_file = $raw_file. '.xmp'; - my $xmp2_file = $filename. '.xmp'; - - print $raw_file .'...'; - - $move_counter++; - # do not move files that have no raw-file anymore - if ( ! -e $raw_file ) - { - print 'raw-file not found!'; - } - 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 - move($outarp_file, catfile($converted_destination_dir, basename($outarp_file))); - move($rawarp_file, catfile($destination_dir, basename($rawarp_file))); - move($rawarp2_file, catfile($destination_dir, basename($rawarp2_file))); - move($xmp_file, catfile($destination_dir, basename($xmp_file))); - move($xmp2_file, catfile($destination_dir, basename($xmp2_file))); - - if ($opt_C ne '' && -d $opt_C) - { - copy($converted_file, catfile($opt_C, basename($converted_file))); - } - - if ( move($converted_file, catfile($converted_destination_dir, basename($converted_file))) && - move($raw_file, catfile($destination_dir, basename($raw_file)) )) - { - print 'moved.'; - } - else - { - print "move failed: $!"; - } - } - say ''; - } - - say "\r\nfound $move_counter files."; -} - -sub getconfig -{ - if ( -f $configfile ) { do $configfile; } -} - -sub writeconfig -{ - open(my $filehandle, '>', $configfile) or die "Could not open file '$configfile': $!"; - say $filehandle '$opt_F="'. $opt_F .'";'; - say $filehandle '$opt_E="'. $opt_E .'";'; - say $filehandle '$opt_R="'. $opt_R .'";'; - say $filehandle '$opt_C="'. $opt_C .'";'; - close $filehandle; -} - -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.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 ''; - say 'usage: afm [options] <target folder>'; - say ''; - say 'options:'; - say ' -l : list-only mode - does not move files but only lists which files would be moved'; - say ' -f <exp> : filter files by regex - only raw files that match the PCRE are processed'; - say ' needs to be quoted'; - say ' -R <raw> : override the raw extensions, defaults to "DNG"'; - say ' This option is automatically saved in the user config and can be omitted on the next run'; - say ' -F <folder> : override the folder for converted files, defaults to "JPEG"'; - say ' This option is automatically saved in the user config and can be omitted on the next run'; - say ' -E <ext> : override the converted file extenion (case-insensitive), defaults to "jp(e)g"'; - say ' Perl-compatible regular expressions allowed'; - say ' This option is automatically saved in the user config and can be omitted on the next run'; - say ' -C <folder> : copy the converted (output) files (ie jpegs) to an additional directory'; - say ' This option is automatically saved in the user config and can be omitted on the next run'; - say ' --help : show this help'; -} diff --git a/jd b/jd @@ -1,99 +0,0 @@ -#!/usr/bin/perl -# Copyright(c) René Wagner 2019-2020 -# https://src.clttr.info/rwa/photo-helpers -# published under BSD 3-Clause License - -use Modern::Perl '2019'; -use Cwd; -use File::Basename; -use File::Copy; -use File::Find::Rule; -use File::Spec::Functions; -use Getopt::Std; - -$Getopt::Std::STANDARD_HELP_VERSION = 'true'; - -my $VERSION = '0.6'; -my $PROGRAM = 'JpegDivider'; - -# read commandline switches -our $opt_l = 0; -our $opt_f = 'JPEG'; -our $opt_e = 'jpe{0,1}g'; - -getopts('lf:e:') or die "Invalid parameters provided! See 'jd --help' for more details."; - -# read remaining commandline args -# last dir will win -my $work_dir = getcwd; -foreach my $arg ( @ARGV ) -{ - if ( -d $arg ) { $work_dir = $arg } -} - -move_files($work_dir); - -exit 0; - -sub move_files -{ - my ( $dir ) = @_; - my $move_counter = 0; - - say "working directory: $dir"; - say 'action : '. (!$opt_l ? 'move' : 'list only'); - say "subfolder : $opt_f"; - say "file ext : $opt_e"; - say ''; - - my $destination_dir = catdir($dir, $opt_f); - if ( !$opt_l && ! -d $destination_dir ) - { - mkdir $destination_dir or die "Could not create destination dir $_ : $!"; - } - - my @files = File::Find::Rule->file()->name( qr/\.$opt_e$/i )->maxdepth(1)->in( $dir ); - - foreach my $file ( @files ) - { - print $file .'...'; - $move_counter++; - if ( !$opt_l ) - { - if ( move($file, catfile($destination_dir, basename($file)) ) ) - { - print "moved."; - } - else - { - print "move failed: $!"; - } - } - say ''; - } - - say "\r\nfound $move_counter jpeg files to subfolder."; -} - -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.sr.ht/~rwa/photo-helpers'; -} - -sub main::HELP_MESSAGE -{ - say ''; - say 'Moves JPEG files to a designated subfolder, by default "JPEG"'; - say ''; - say 'usage: jd [options] <target folder>'; - say ''; - 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'; -}