Hi,I can get all of the filenames but am not sure how to also get the subfolder's names. Please help.truncate table Reports goIF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #tempCREATE TABLE #temp([files] [nvarchar](50) NULL--[Warrants] [nvarchar](50) NULL,-- [Statement] [nvarchar](50) NULL,-- [Property Tax] [nvarchar](50) NULL) ON [PRIMARY]goINSERT INTO #tempEXEC xp_cmdshell 'dir D:\Reports /b';WITH cte AS( SELECT CASE WHEN files LIKE '%stmt.pdf' THEN 'stmt' WHEN files LIKE '%tax.pdf' THEN 'tax' WHEN files LIKE '%warr.xls' THEN 'warr' END AS FileType, REPLACE(REPLACE(REPLACE(files,'stmt.pdf',''),'tax.pdf',''),'warr.xls','') AS FILENAME, files FROM #temp)INSERT INTO Reports([Statement],[Property Tax],[Warrants], [FileName])SELECT stmt, tax, warr, FileNameFROM ctePIVOT(MAX(files) FOR filetype IN ([stmt],[tax],[warr]))p