Renaming a file based on a folder name for XBMC

Hello all. I have looked through the resources here and found a similar post but am feeling a little overwhelmed as I am not a coder nor have I ever really used apple scripts except on the most elementary level.

I am trying to figure out how to take a folder with my movie poster jpgs, duplicate the file, rename it to the same name as the folder in which it resides and change the extension to .tbn.

This would allow me to use all my existing art that I have accumulated for my movies and videos on my newly built EVTV running XBMC (xbox media center). The file structure on the xbmc says files must be formatted as follows:


Any help is truly appreciated. Thanks in advance.

Try this.
Change the ‘basefolder’ variable to the folder with everything in.

-- Applescript alias is similar to a path. But has the HD name and ':' instead of '/'.
set basefolder to ((path to home folder) as text) & "Code Box:Applescript:Test Area:Movies:"

tell application "Finder" to set allfolders to (list folder basefolder)

repeat with i from 1 to (the number of items in allfolders)
	tell application "Finder" to set allfiles to (list folder (basefolder & (item i of allfolders) as text))
	repeat with picnum from 1 to (the number of items in allfiles)
		if characters -1 thru -4 of item picnum of allfiles is {".", "j", "p", "g"} then
			exit repeat
		end if
	end repeat
	tell application "Finder"
		duplicate ((basefolder & (item i of allfolders) as text) & ":" & (item picnum of allfiles) as text) to basefolder
		set name of file (basefolder & (item picnum of allfiles) as text) to ((item i of allfolders) as text) & ".tbn"
	end tell
end repeat