SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How to get complete file names in many folders

Accepted Solution Solved
Reply
Contributor
Posts: 52
Accepted Solution

How to get complete file names in many folders

I have many folders. In each of them, there are a number of files.  Is there a quick way to get all file names automatically?  For example, for the attached figure, I hope to get names, such as ABB006.dat, ABB0012.data, etc.

 

Thank you.


get_file_name.jpg

Accepted Solutions
Solution
‎01-14-2016 11:37 AM
Trusted Advisor
Posts: 1,115

Re: How to get complete file names in many folders

How about this?

filename flist pipe 'dir C:\Temp /a-d/b/s'; /* please enter your parent folder */

data fnames;
length fname $400; /* please adapt the length up/down as necessary/convenient */
infile flist;
input;
fname=scan(_infile_,-1,'\');
run;

View solution in original post


All Replies
Super User
Posts: 5,260

Re: How to get complete file names in many folders

"Automatically" is a strong word, what is your requirement? And what shall you do with them?

You could use data step extrnal file functions, or use a filename to pipe the dir/ls command.

Are you using DI Studio?
Data never sleeps
Solution
‎01-14-2016 11:37 AM
Trusted Advisor
Posts: 1,115

Re: How to get complete file names in many folders

How about this?

filename flist pipe 'dir C:\Temp /a-d/b/s'; /* please enter your parent folder */

data fnames;
length fname $400; /* please adapt the length up/down as necessary/convenient */
infile flist;
input;
fname=scan(_infile_,-1,'\');
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 252 views
  • 1 like
  • 3 in conversation