SharePoint File Name Auto Truncate
Let SharePoint give you the option of automatically truncating the file name so it fits within the 260 character limit. So you don't have to figure out how many characters to reduce your file name by.
Instead of truncating, why not remove the character limit or at least increase it. Why put a band aide on it and not fix the actual problem.