Solved it, here is the dialplan code so far:
[directory-lookup]
exten => s,1,Verbose(1,Want to list files in ${BOOK})
; set some initial values
exten => s,2,Set(x=1)
exten => s,3,Set(file=a)
; execute the shell command to list the files
exten => s,n,Set(result=${SHELL(echo ${BOOK}*)})
exten => s,n,NoOp(result from shell is = ${result})
; replace hyphen with an _ for now
exten => s,n,Set(tmp=${REPLACE(result,-,)})
; now filter out anything we don’t want like the path and silly cr/lf
; I only allow numbers, cap letters, dots and underscores
exten => s,n,Set(tmp2=${FILTER(0-9A-Z.,${tmp})})
; now replace the _ with a - to put it back (I couldn’t figure to filter the -)
exten => s,n,Set(tmp3=${REPLACE(tmp2,_,-)})
; we will now use tmp3 to get each filename which should be delimited with a .
exten => s,n,NoOp(tmp3 = ${tmp3})
exten => s,n,Answer()
exten => s,n(loop),Set(file=${CUT(tmp3,".",${x})})
exten => s,n,NoOp(file is “${file}” and x is ${x})
exten => s,n,Set(x=$[${x}+1])
exten => s,n,Set(tmp=book/${file})
exten => s,n,NoOp(tmp = ${tmp})
exten => s,n,Playback(${tmp})
exten => s,n,GotoIf($["${file}" != “”]?loop)
exten => s,n,Hangup()
If anybody wants my dialplan for storing the number and then selecting the number please PM me (well leave it a few days because it’s not quite finished yet)