Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
saivina2920
Creator
Creator

How to Load excel file name from specific folder into listbox

I am having multiple Excel file in my specific folder. I just want to fetch all the file excel filname in my list box.

For example,

C:\Test\sample1.xlsx

               \sample2.xlsx

                ......................

              \sample10.xlsx

              .......................

In my listbox, i just want to list all the file such as "sample1.xlsx,sample2.xlsx,.......sample10.xlsx".....) 

file is dynamic and it should automatically load into listbox.

 

Labels (1)
1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

To get only first part of filename and get all files, not just excel:

For Each vFile in FileList('C:\Projects\*.*')

	Let vFileBase = SubField(SubField(vFile, '\', -1), '_', 1);
	
	Files:
	LOAD '$(vFileBase)' as FileName
	Autogenerate 1;
	
Next
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

6 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Something like:

For Each vFile in FileList('C:\Test\sample*.xlsx')

	Files:
	LOAD FileBaseName() as FileName
	FROM [$(vFile)]
	(ooxml);
	
Next

Now use FileName in your listbox.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
saivina2920
Creator
Creator
Author

Thanks for your reply.

I want to trim and get only first words of every filename.

Filename will be : sample1_20190_989.xlsx, sample2_20190_989.xlsx,Test101_20190_989.xlsx,etc

So final list box would be 

sample1

sample2

Test101

i am getting Script error.

Error Details below :

LOAD FileBaseName() as ProjectName
FROM [C:\projects\~$101_210_Main report.xlsx]
(ooxml)

Note : File name may be anything. so i want get all the files from the folder.

 

chrislemm
Partner - Contributor III
Partner - Contributor III

If you want to use wildcards in your filenames you can replace the "wild"-part with an *.

For example:

SET vPathFilter = '<filepath\*_specific_file_ending.xlsx';
For Each vTempFile in FileList('$(vPathFilter)')
Images:
LOAD
'$(vTempFile)' as FileName
AutoGenerate(1);
Next

saivina2920
Creator
Creator
Author

Thanks..

not load the corrected script.

SET vPathFilter = '<C:\Projects\\*_.xlsx>';
For Each vTempFile in FileList('$(vPathFilter)')
Images:
LOAD
'$(vTempFile)' as FileName
AutoGenerate(1);
Next

"FileName" not loading in the listbox. i'm using wild *_ to use first word...

 

jonathandienst
Partner - Champion III
Partner - Champion III

To get only first part of filename and get all files, not just excel:

For Each vFile in FileList('C:\Projects\*.*')

	Let vFileBase = SubField(SubField(vFile, '\', -1), '_', 1);
	
	Files:
	LOAD '$(vFileBase)' as FileName
	Autogenerate 1;
	
Next
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
saivina2920
Creator
Creator
Author

Excellent. Its working...