Every time I have to do this, I Google for a script. I might as well write my own and put it here so at least I find myself in the Google results:
SELECT 'ALTER DATABASE tempdb MODIFY FILE (NAME = [' + f.name + '],'
+ ' FILENAME = ''Z:\MSSQL\DATA\' + f.name
+ CASE WHEN f.type = 1 THEN '.ldf' ELSE '.mdf' END
FROM sys.master_files f
WHERE f.database_id = DB_ID(N'tempdb');
The results: I can then copy/paste the results into SSMS, edit them, and run ’em. I like generating scripts like this…