How to identify the db orphan mdf and ldf files
The files in C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQL\MSSQL\Binn\Templates are basic copies of the system databases that are needed for repairing and rebuilding your system dbs in case of problems - http://msdn.microsoft.com/en-us/library/dd207003(v=sql.105).aspx

While you could delete them, you'll be in for a longer recovery period if you need to rebuild the system dbs as you'll need to find the templates from somewhere else.

But other than that, that script appears to do what it proclaims to do. Though, it should be updated to:


select 
    os.filename as orphaned_files 
from 
    #os_files os
    left outer join master.sys.master_files db on rtrim(db.physical_name) = os.filename
where 
    db.database_id is null


as sysaltfiles is deprecated and will be removed from SQL Server in a future version.