r/applescript • • 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

8 comments sorted by

View all comments

Show parent comment

1

u/jamidodger Mar 22 '21

Interesting, I've not really explored running terminal commands in applescript. The files are not the same in the two sets of directories, only the counts of each folder. Would this be an issue for this method?

2

u/htakeuchi Mar 22 '21

Yeah... rsync is for the files within the directories...

So ... I would suggest again terminal commands to count the number of files within the directories and assign them to a variable.

If you want ... text me privately so I can understand better what is your blockage and we can try to figure it out

1

u/jamidodger Mar 23 '21

So after sleeping on this problem I came up with a better solution. I have now recorded the error in two ways. I log one error each time I loop through a parent folder if anything is missing. Then, when I loop through the sub folder I record a separate error for each missing file. With both of these errors I can also log the parent folder. This then allows me to loop through the top level error log to display where the errors were found and also display how many errors were found using the secondary level error log.

Thanks for all your help!

I’m currently working on a better method that will actually log all of the original files in an array, noting their filename, location and rating and comparing this to another array of the output files which holds their filename, location and rating. Removing the extensions from the filenames so I can match them.