Installing Both MacOS and Unix

Started by Geoff_12889, August 01, 2023, 02:01:00 PM

Previous topic - Next topic

Geoff_12889

Is it fine to install both ways?


wywh

I have always installed from the MacOS Package .dmg from exiftool main page.

https://exiftool.org

Instead Homebrew I use MacPorts but I prefer to use precompiled apps, if available.

- Matti

Geoff_12889

I don't believe the MacOS packaged .dmg allows using ExifTool in Perl scripts

Geoff_12889

Also just now noticed that the Homebrew version of ExifTool is 12.60 and not the current release 12.64

wywh

Quote from: Geoff_12889 on August 01, 2023, 02:19:01 PMusing ExifTool in Perl scripts

What such scripts might be useful (enquiring minds want to know)?

- Matti

Geoff_12889

I'm just a novice (hence posting in the Newbie section), but I have the start of a script for some file management and organization.

#!/usr/bin/perl
use strict;
use warnings;
use File::Copy;
use Image::ExifTool;

my $full_file_path = "~/desktop/2023-07-08 __ 11.47.18 __ X100V __ DSCF0242.jpg";
my $path = $full_file_path;
$path =~ s{/\d{4}-\d{2}-\d{2} __ \d{2}.\d{2}.\d{2} __ \w+ __ \w+\.\w{3}$}{};
my $filename = $full_file_path;
$filename =~ s{\.jpg}{};
$filename =~ s{$path}{};
$filename =~ s{/}{};
my $type = Image::ExifTool::GetFileType($full_file_path);
my $fileinfo = ImageInfo($full_file_path);

opendir(DIR, $path) or die "Can't open $path: $!";

my @list = grep {/^\w/ && !/jpg$/ && -f "$path/$_"} readdir (DIR);

my $file;
my $i = 1;

foreach $file (@list){

    $file =~ s{\.\w+$}{};
    if ($file eq $filename){
        printf "$file is a MATCH!!!!!!!\n";
        mkdir("JPEG Backup");
        move($full_file_path, $path . "/JPEG Backup");
        last;
    }
    printf "$i: $file\n";
    $i++;

}

closedir(DIR);

exit 0;

Phil Harvey

Quote from: Geoff_12889 on August 01, 2023, 02:19:01 PMI don't believe the MacOS packaged .dmg allows using ExifTool in Perl scripts

It does, but you need to add /usr/local/bin/lib to @INC in a BEGIN block before using any of the ExifTool modules:

#!/usr/bin/perl
use strict;
use warnings;
use File::Copy;
BEGIN { unshift @INC, '/usr/local/bin/lib' }
use Image::ExifTool;
...

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).