Here is a simple script that reads the file names from a specified directory.
The results are held in a table that can be referenced, and then dropped when the script has completed.
declare @DIR as varchar(100)
set @DIR = ‘dir c:\’ — ENTER DIRECTORY PATH HERE
create table files_TMP (filenames varchar(max))
insert into files_TMP
exec master..xp_cmdshell @DIR
select * from files_TMP
drop table files_TMP