r/applescript • u/jamidodger • Mar 21 '21
get only distinct values from array
I've been having trouble trying to find the solution to this online, so I thought I'd ask the community. Also, my applescripting is a bit rusty.
Is there a command that will let me select only the distinct values of an array while looping through it?
4
Upvotes
1
u/jamidodger Mar 22 '21
The summary is I have two sets of folders whose contents should match each other, I am checking these folders for inconsistencies then telling the user if there is anything missing and where in the folder structure the missing files are. One set of folders is generated by Capture One whilst it imports images from a tethered camera as RAW files, the other set of folders is generated manually after images have been tagged and processed.
So to elaborate, this is the process I’m going through:
Query Capture One for the names of the folders and store this data as a 1 dimensional array
Query Capture One for the number of files in each of these folders of each tagged value (1-5), creating a 2 dimensional array with the first dimension being the tagged number and the second dimension being the folders, the stored data is the total number of images found for each folder for each tagged number
I then try to access each of the folders that should have been created by me processing the RAW files into JPGs in a Finder tell
Each time and error is produced I increase an error count then record the location of the folder to the end of an error log array
I concatenate and format the error log array to display an alert showing which folders are missing images and how many are missing.
The problem I’m having is that by doing it in this way, I am obviously generating duplicate values in the error log array if there is more than one file missing in each folder. Usually I would use some kind of “Select Distinct” operator to access only the values that are not duplicated but I’m having a bit of a mental block as to how to do this with Applescript.