Grep returns one line per match; There are multiples matches because your pattern only matches a single character.
Try something like this:
set oldFolderName to "140202_InKindRoll123"
do shell script "echo " & quoted form of oldFolderName & " | /usr/bin/grep --only-matching '[^0-9]\\+$'"
set baseFolderName to result
That said, I’m not sure how reliable that pattern is. StefanK’s previous post should be a good alternative.
set oldFolderName to "140202_InKindRoll123"
do shell script "echo " & quoted form of oldFolderName & " | /usr/bin/sed 's/^[0-9]\\{1,\\}//'"
set baseFolderName to result
PS: in a repeat loop with a hugh amount of iterations this could be faster.
set oldFolderName to "140202_InKindRoll123"
set baseFolderName to skipLeadingDigits(oldFolderName)
on skipLeadingDigits(d)
repeat with i from 1 to count characters of d
try
character i of d as integer
on error
return text i thru -1 of d
end try
end repeat
end skipLeadingDigits
[2addr]s/regular expression/replacement/flags
Substitute the replacement string for the first instance of the
regular expression in the pattern space. Any character other
than backslash or newline can be used instead of a slash to
delimit the RE and the replacement. Within the RE and the
replacement, the RE delimiter itself can be used as a literal
character if it is preceded by a backslash.
regular expression; ^[0-9]* that means all(*) digits([0-9]) at the beginning(^) replacement: none flags: none