Perform a set of actions for a specific file type

Hello, I have a problem that I'm having quite a bit of trouble with.

I am trying to create a script that performs a specific sequence of actions for a file of a specific type.

This is an abbreviated version of my basic script:

#!/bin/sh

#coulombic calculations
./APBS/share/tools/manip/coulomb ./$1.pqr >> ./$1.coulomb.txt

#polar calculations
./psize.py $1.pqr >> $1.psize.txt
./apbs-create.out $1
apbs $1.apbs.in | tee $1.apbs.out

That $1 argument that you see is the name of a PDB file. For example, ./script XXXX would mean XXXX.pdb. The thing is, the program works when the script is ran for each PDB file individually, but it is rather time consuming. I would rather create some sort of For... loop that scans every file in a specific folder and runs this set of commands if it is a .PDB file.

I know that you can use $ echo "file.txt" | awk -F . '{print $NF}' to print out the extension, and I would imagine that I can add an If... statement to test whether that output is PDB, but I don't know how to get the shell to do this for every file in the folder. I'm ridiculously new to scripting and my previous experience with programming is helping me very little.

I was thinking about using dir to create a list of all .PQR files, i.e.
dir *.pdb > file_list.txt and then using this command that I found online echo $(basename $F | awk -F. -v OFS=. '{$NF=""; sub("[.]$", ""); print}') to extract just the file name. The thing is, with this I would have to read a file line by line in the script and I don't know how to do this yet. I will try this and if it works I will update the thread with the results. crosses fingers

I apologise in advance if this question has already been addressed and I overlooked it.

EDIT:
I actually feel rather foolish, because I found this: actions based on file type almost immediately after posting this thread. It looks like my answer was in fact already there. I apologise for that.

Here's how I did it, in case anyone is interested.

for F in `dir *.pqr`
do
filename=`basename $F .pqr`
echo $filename
#coulombic calculations
/scratch/XXXX/APBS/share/tools/manip/coulomb ./$filename.pqr >> ./$filename.coulomb.txt

#polar calculations
./psize.py $filename.pqr >> $filename.psize.txt
./apbs-create.out $filename
apbs $filename.apbs.in | tee $filename.apbs.out

done

i see you use a Python script psize.py. For every file found, you call this script and some other tools, which is very inefficient. If I were you , i would do everything in that Python script.
eg

import os,sys,glob
coulomb = os.path.join("/","scratch","XXXX","APBS","share","tools","manip","coulomb")
for files in glob.glob("*.pqr"):
    filename = files[-4:] #equivalent to your basename command
    fin,fout = os.popen4(couloumb)
    <psize.py code here>
    < and the rest....>
    ......
    ........