I'm using this solution https://stackoverflow.com/a/10341883/6400605 to get a list of files from a specified folder, with a predefined -name variable, but it does not work when supliying a directory argument.
#!/bin/bash
if [ -n "$1" ] && [ -f "$1" ] ; then snames=$(basename "$1") ; fi
if [ -n "$1" ] && [ -d "$1" ] ; then snames=( '\* address.txt' -o -name '\*.log' -o -name '\*.rtf' -o -name '\* @unit credentials.doc' ) ; fi
start="$(dirname "$1")";
find "${start}/" -type f \( -name "${snames[@]}" \) -print0 | xargs -r0 -n1 bash -c '
echo "$2"
# ....more commands below
' _ \;
This works when providing a path+filename, however does not work when providing a directory argument.