Exclude Alias's from Dataset

Started by Chris S, March 14, 2023, 03:52:51 PM

Previous topic - Next topic

Chris S

Is there a way to bypass aliases when searching for metadata?

For example, the code below will give me all PSD and PNG files, including those that are alias's (FileType=Alias; FileTypeExtention=alias). How could I amend this to exclude the aliases?

exiftool -ext psd -ext png [tags][dir]

Phil Harvey

One way would be to add this to the command:

-if3 "$filetype ne 'Alias'"

(I'm thinking that the fast 3 level is the highest you can go and still properly identify an alias file.)

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

Chris S

Can you help me escape this properly with AppleScript's do shell script? I've tried the two cases below but both still return the alias.

do shell script "//usr/local/bin/exiftool -if3 \"$filetype ne 'Alias'\" -filename " & folder_path

set the_cmd to quoted form of "$filetype ne 'Alias'"
do shell script "//usr/local/bin/exiftool -if3 " & the_cmd & " -filename " & folder_path

Phil Harvey

As per my signature, on Mac you need single quotes around the "$".  I'm not sure what "quoted form" is doing, but the command should look like this in the end:

/usr/local/bin/exiftool -if3 '$filetype ne "Alias"' ...

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

Chris S

Embarrassing. Thank you for that tip/reminder. Unfortunately it doesn't seem to recognize the alias as it's still being returned. Thought it was maybe I was escaping incorrectly but it's not working as expected directly from the Terminal... the PSB here is actually an Alias.

> exiftool -if3 '$filetype ne "Alias"' -filename [DIR]
======== ...
File Name                       : This is a TIFF.tif
======== ...
File Name                       : This is an alias.psb
    1 directories scanned
    2 image files read

Phil Harvey

You'll have to run some tests to see what the FileType is:

exiftool -filetype DIR

- Phil

Edit: I ran the test myself.  (Lucky for you I'm on MacOS myself.)  The type is "ALIAS", not "Alias", so this needs to be changed in your command.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Chris S

Ah ha... looks like it's case sensitive. Filetype is ALIAS. Changing it to all uppercase in the code correctly excluded the alias this time. Thank you!

> exiftool -if3 '$filetype ne "ALIAS"' -filename [DIR]
======== ...This is a TIFF.tif
File Name                       : This is a TIFF.tif
    1 directories scanned
    1 files failed condition
    1 image files read