I have written a script that finds files in directories, and brings through if statement, here is a code:
for dirname in /input/*; do
    id=${dirname#/input/}    # remove "/input/sub-"
    id=${id%/}             # remove trailing "/"
    printf 'Adding ID to recon-all processing list: %s\n' "${id}" >&2
    T11=`find /input/${id}/unprocessed/3T -name "*T1*MPR1*" -type f`
    T12=`find /input/${id}/unprocessed/3T -name "*T1*MPR2*" -type f`
    T21=`find /input/${id}/unprocessed/3T -name "*T2*SPC1*" -type f`
    T22=`find /input/${id}/unprocessed/3T -name "*T2*SPC2*" -type f`
    if [ -z "$T11" ] || [ -z "$T12" ] || [ -z "$T21" ] || [ -z "$T22" ]; then
        recon-all -s "${id}" -i "${T11}" -i "${T12}" -i "${T21}" -i "${T22}"
    elif [ -z "$T11" ] || [ -z "$T12" ] || [ -z "$T21" ]; then
        recon-all -s "${id}" -i "${T11}" -i "${T12}" -i "${T21}"
    elif [ -z "$T11" ] || [ -z "$T12" ] || [ -z "$T22" ]; then
        recon-all -s "${id}" -i "${T11}" -i "${T12}" -i "${T22}"
    elif [ -z "$T11" ] || [ -z "$T21" ]; then
        recon-all -s "${id}" -i "${T11}" -i "${T21}"
    elif [ -z "$T11" ] || [ -z "$T22" ]; then
        recon-all -s "${id}" -i "${T11}" -i "${T22}"
    else 
        recon-all -s "${id}" -i "${T11}" -i "${T21}" 
    fi
    if [ -e "/output/$subj_id" ]; then
        # no output file corresponding to this ID found,
        # add it to he list
        all_ids+=( "$subj_id" )
    fi
done
The problem is that there could be different combination inside directories, and T12 and T22 could sometimes be missed, that's why I made a recon-all for every statement. How could I simplify if statements and parallel this script?