Yes I was using the find and replace panel. I have used it many times for other things in metadata and it worked fine but in this case, with these bits of filename, it does the replacement but then the items are not dealt with properly by the database.
Thanks very much for the comment about {filenamebase:-4} this sounds just what I want.