I remember, in the early 80's, traveling by train from Paris to Madrid. At the border station Hendaye, which was incredibly big, with a huge depot, turntable, etc. the locomotive (French) was replaced by a Spanish one and all the coaches which were to enter Spain, mostly couchettes and sleeping cars, had to be lifted from their bogies (standard gauge in France) and placed on (wide gauge Spanish) bogies waiting on the track next to the train. It all went extremely smooth without any shaking or bumping at all.
Outside the main station there was also a narrow gauge railroad, it crossed the border into Spain too (connecting to the extensive narrow gauge system in northern Spain, FEVE) and had it's own border station with customs. Passengers boarded the narrow gauge train ( I think it was a railcar, it looked somewhat like a tram/streetcar, old style ) and it brought them to a tiny station which was exactly on the border between France and Spain. Passengers had to get off the train there, enter the building in which customs employees checked passports and luggage and after the check they had to leave the building through another door, on the same side as the first door, and they had to enter the train again. The narrow gauge train continued into Spain and ended on a mid sized narrow gauge station called San Sebastian, there people could change to other narrow gauge gauge trains traveling deeper into Spain.