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 4f5e1eed7526f031a7bae7bbfc18b5e980567a5b
Author: René Wagner <apollo@rw-net.de>
Date:   Sat, 28 Sep 2019 10:25:20 +0200

upload scripts

Diffstat:
ACONTRIBUTING.md | 8++++++++
ALICENSE | 29+++++++++++++++++++++++++++++
AREADME.md | 17+++++++++++++++++
Aorphaned_sidecar_cleaner.pl | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 148 insertions(+), 0 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +Visual Studio 2017 Community Edition is required for building the application. + +If you want to contribute, do it the following way: +- pick an issue and mention there that you will contribute +- create a personal fork +- push your changes to your fork +- create a merge request mentioning the implemented issue +\ No newline at end of file diff --git a/LICENSE b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2018, René Wagner +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md @@ -0,0 +1,16 @@ +# Silkypix Helper Scripts +This rather small scripts written in [Perl](https://perl.org) provide useful function for managing the sidecar data files created by [Silkypix Developer Studio](https://silkypix.isl.co.jp/en/). + +## required perl modules +The following perl modules are required for running the scripts. +- Cwd +- File::Spec +- File::Basename +- File::Find::Rule +- File::Find +- Switch + +## description + +## orphaned sidecar cleaner +Deletes all sidecar files in the given directory or alternatively in the current working directory when the associated raw file is missing. +\ No newline at end of file diff --git a/orphaned_sidecar_cleaner.pl b/orphaned_sidecar_cleaner.pl @@ -0,0 +1,93 @@ +#!/usr/bin/perl + +use warnings; +use strict; +use Cwd; +use File::Spec; +use File::Basename; +use File::Find::Rule; +use File::Find; +use Switch; + +my $VERSION = 0.1; +my $PROGRAM = 'Orphaned Sidecar Cleaner'; + +# parse commandline args +# last dir will win +my $delete_flag = 0; +my $delete_dir = getcwd; + +foreach my $arg ( @ARGV ) +{ + switch ( $arg ) + { + case '-h' { show_help(); exit; } + case '-d' { $delete_flag = 1; } + else { if ( -d $arg ) { $delete_dir = $arg } } + } +} + +print "working directory: $delete_dir \r\n"; + +main($delete_dir, $delete_flag); + +exit 0; + +sub main +{ + my ( $dir, $delete ) = @_; + my ( $delcounter ) = 0; + + # alle Dateien in allen Unterordnern *.spd *.spf suchen + my $rule = File::Find::Rule->new; + $rule->file; + $rule->name( '*.spd', '*.spf' ); + my @files = $rule->in( $dir ); + + my $file; + foreach $file ( @files ) + { + my $rawfile = get_raw_filename($file); + + if ( ! -f $rawfile ) + { + print $file .'...raw file not found!'; + $delcounter++; + if ( $delete ) + { + print " Deleting"; + unlink $file or warn " failed: $!"; + } + print "\r\n"; + } + } + + print "Found $delcounter orphaned sidecar files found.\r\n"; +} + +sub get_raw_filename +{ + my ( $original_file ) = @_; + + my ( $filename, $dirs ) = fileparse($original_file); + # Silkypix Sidecar files reside in a "SILKYPIX_DS" folder, so we need to search in the parent folder + $filename =~ s/\.\d+\.sp.$//g; + return dirname($dirs) .'/'. $filename; +} + +sub show_help +{ + print $PROGRAM . ' - version ' . $VERSION . "\r\n"; + print "published under BSD 3 - Clause License \r\n"; + print "Copyright(c) 2018-2019, René Wagner\r\n"; + print "https://gitlab.com/guzzisti1/rawfilewizard \r\n"; + print "\r\n"; + print "Deletes Silkypix Sidecar files when corresponding RAW files are missing.\r\n"; + print "\r\n"; + print "commandline parameters:\r\n"; + print "orphaned_sidecar_cleaner.pl - list orphaned sidecar file in current working directory and subfolders\r\n"; + print "orphaned_sidecar_cleaner.pl -d - delete orphaned sidecar file in current working directory and subfolders\r\n"; + print "orphaned_sidecar_cleaner.pl <folder> - list orphaned sidecar file in given directory and subfolders\r\n"; + print "orphaned_sidecar_cleaner.pl -d <folder> - delete orphaned sidecar file in given directory and subfolders\r\n"; + print "orphaned_sidecar_cleaner.pl -h - show this help\r\n"; +} +\ No newline at end of file