Rename File Failing

I'm running an AppleScript that finds a video's resolution via ffprobe and appends it to the file name. No problem with ffprobe or building the new file name, but adding the extension back onto the file name is failing. Any advice?
- Code: Select all
tell application "Finder"
-- get filename and extension
set theEpisodeName to name of theFile
set theExtension to name extension of theFile
--get the filename without extension
set theEpisodeName to text 1 thru ((theEpisodeName's length) - (offset of "." in (the reverse of every character of theEpisodeName) as text)) of theEpisodeName
-- get video resolution
set theEpisode to quoted form of POSIX path of theFile
set theWidth to do shell script ("/usr/local/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=width " & theEpisode & " | cut -d \"=\" -f2")
set theHeight to do shell script ("/usr/local/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height " & theEpisode & " | cut -d \"=\" -f2")
set theResolution to space & "(" & theWidth & "x" & theHeight & ")"
-- build new filename with extension
set newEpisodeName to theEpisodeName & theResolution & "." & theExtension
set name of theFile to newEpisodeName
end tell