sorting file names with hyphen and underscore

Hi,

I have two types of file names

filename1_12345 or filename1-12345 at the same time I have second type
filename2-12345 in a txt file.

I am trying to write awk script that will sort these names with below pattern

ALL file names like
filename1_12345 and filename1-12345 will go to folder1 (lets say same directory)
filename1_23451and filenmae1_23451 will go to folder2

filename1_34512 and filename1_34512 will go to folder 3

till 9

and rest all filename2- whaterever will go to folder-temp

all the these files are listed in a txt file and I can use move command to move.

can you please give me a direction to sort for numbers.

awk -F '[-_]'  '/$1 ~ 2$/ {print "mv", $0, "./folder-temp/" $0; next}
                   { where=substr($1,length($1)-1,1); where="./folder" where;
                      print "mv", $0, where "/" $0} 
                   ' inputfile > shell.sh
# visually check the file
more shell.sh

If shell.sh looks good make it runnable, then run it:

chmod +x shell.sh
./shell.sh