Browse Source

Deleted scripts/README.md, scripts/orphaned_sidecar_cleaner.pl, scripts files

master
rwa 2 years ago
parent
commit
5bcdf4bc90
  1. 16
      scripts/README.md
  2. 93
      scripts/orphaned_sidecar_cleaner.pl

16
scripts/README.md

@ -1,16 +0,0 @@
# 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.

93
scripts/orphaned_sidecar_cleaner.pl

@ -1,93 +0,0 @@
#!/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";
}
Loading…
Cancel
Save