Re: Easier way to check for numbered string
Re: Easier way to check for numbered string
- Subject: Re: Easier way to check for numbered string
- From: "Stockly, Ed" <email@hidden>
- Date: Fri, 27 Apr 2007 12:39:10 -0700
- Thread-topic: Easier way to check for numbered string
Title: Re: Easier way to check for numbered string
> I have a script that goes through and pulls specific characters
> out of a filename and checks to see if they are all numbers. While
> it works now, I was hoping somebody knew of a more efficient way of
> doing this.
This may not be the most efficient way of doing it, but it works for me.
You can adjust the values of the variable positionsToTest to pick any characters in your file name.
The result is a list of the file names that failed.
HTH,
ES
---------------------
set fileNames to {"No Numbers", "1234567890", "12andletters", "lettersand12"}
set allNumbers to {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
set text item delimiters to ""
set failedTest to {}
repeat with thisName in fileNames
set nameStringlist to every text item of thisName
set positionsToTest to {-1, -2} --last 2 numbers
--set positionsToTest to {1, 2} -- first 2 numbers
--set positionsToTest to {1, 2, 4, -1, -2} --arbitrarily selected numbers
repeat with thisNumber in positionsToTest
if the (count of nameStringlist) ≥ thisNumber then
if item thisNumber of nameStringlist is not in allNumbers then
set the end of failedTest to thisName as string
exit repeat
end if
end if
end repeat
end repeat
return failedTest
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden