Remove folder name from file name based on existing Apple Script
You can get the file name, then set the text item delimiter to the containing folder name, then put the text items of the file name into a list, which will ignore the delimiter (the folder name), then reset the text item delimiter to "" empty and coerce the name to a string. This is a VERY common Applescript trick.

set the_folder to (choose folder)
renamefilesinside(the_folder)

on renamefilesinside(next_folder)
    tell application "Finder"
        set folder_name to name of next_folder
        set folder_contents to every item of next_folder
        repeat with each_item in folder_contents
            if kind of each_item is "folder" then
                my renamefilesinside(each_item)
            else
                set n to name of each_item
                set AppleScript's text item delimiters to folder_name
                set n to text items of n
                set AppleScript's text item delimiters to ""
                set n to n as string
                set name of each_item to n
            end if
        end repeat
    end tell
end renamefilesinside