Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
Hope everyone is doing good.
I'm working on a requirement where i have multiple folders, Say
C:\QVDATA\Folder1;
C:\QVDATA\Folder2,and
C:\QVDATA\Folder3;
I wanna navigate to every folder and select all the files with ".XLS" extension.
I tried using For loop but not getting executed.
Can someone throw some limelight ..
Thanks in Advance.
You can use a For Each file In FileList() loop for that, there is even an example in the HELP that does pretty much what you want:
// list all QV related files on disk
SUB DoDir (Root)
FOR Each Ext in 'qvw', 'qva', 'qvo', 'qvs'
FOR Each File in filelist (Root&' \*.' &Ext)
LOAD
'$(File)' as Name,
FileSize( '$(File)' ) as Size,
FileTime( '$(File)' ) as FileTime
autogenerate 1;
NEXT File
NEXT Ext
FOR Each Dir in dirlist (Root&' \*' )
call DoDir (Dir)
NEXT Dir
ENDSUB
CALL DoDir ('C:')
If you want to read xls files, use the appropriate extensions in the filelist (...in 'xls', 'xlsx') and create an appropriate LOAD statement in the loop body.