The following code in a Zsh script, when passed the first folder and second folder (in that order) will list the files in the first folder that are not found in the second folder. Tested on macOS 13.3.1 with Zsh 5.9.
#!/bin/zsh
# arrays
typeset -a firstdir=() otherdir=() diffdir=()
# in case tilde paths passed in the Terminal need smacked into absolute (:a) paths
SRCDIR="${1:a:s/\~\//}"
NXTDIR="${2:a:s/\~\//}"
# just put the sorted (on) filename.ext in the arrays using :t
firstdir=( ${SRCDIR}/*(.Non:t) )
otherdir=( ${NXTDIR}/*(.Non:t) )
# array difference comparison, use the * operator for intersections of common elements
diffdir=( ${firstdir:|otherdir} )
# print out the tilde path to each file in diffdir
print -Dl ${${diffdir}:a}
unset firstdir otherdir diffdir
exit 0
If have two folders on my Desktop and the first selected folder has two files not present in the second folder. This script lists those two files from the first folder — when run as a Zsh script, or interactively input in the Terminal.
The same code doesn't display an error but is ignored in a Shortcuts Run Shell Script even when one can confirm that the selected folders are passed in by selection order. This wouldn't happen in an Automator Run Shell Script.
Shortcuts is Apple's strategic direction away from Automator, but for some solutions, it costs considerable time to get a working shortcut that should take five minutes to implement in Automator.