Applescript if statement : greater than and lower than
Change:

else if theLength &gt; 4 and &lt; 6 then


To:

else if theLength &gt; 4 and theLength &lt; 6 then


Or, since you asked "Can I run a script if a variable is between 4 and 6 characters only?", which is equal to 5, you can also use:

else if theLength = 5 then


In place of:

else if theLength &gt; 4 and theLength &lt; 6 then


However, if testing between two numbers that are (one or) more then one, just use the variable twice in the test as shown above.