Trying a "complex" if statement, is the theory rig

Basically i wish to seperate this format of a filename
######-XXX.jpg

where # is a number.

What i thought was can i do:

if first 6 characters are in {0,1,2,3,4,5,6,7,8,9} then
Do some grovvy wicked stuff
end


else if Characters 1 through 6 in upColVal is in {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} then

This code compiles but doesnt do much.

Also would like to add

9} and next 3 characters are letters and ends with “.jpg” then

Would that work??? i guess the logic is right just the if statement.

Maybe if i used a repeat to go through the characters, but this wouldnt really be fast.

Any ideas?

A typical work for grep:

set testName to "999999-aXX.jpg"
try
	do shell script "echo " & testName & " | egrep -e [0-9]{6}-[[:alpha:]]{3}\.jpg"
	--> file name ok, go ahead!
on error --> invalid file name!
	--> do whatever
end try

See “man grep” or search google for more info on this powerful tool…