I don't even know a complicated way, and quick browse through the SRD yielded nothing. If Dreamscarred Press's Ultimate Psionics is available to you, I vaguely recall a weapon enhancement there that would do what you want. Even further afield there was 3rd party supplement for D&D that provided a spell that does exactly what you want. If you're bent on staying within pathfinder the only thing I can think of is elemental spell which will convert all spell damage to cold. If it's a spell that requires an attack roll, such as scorching ray, I do believe that would meet the letter of your requirements, though likely not the spirit.