Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

FileName(),FileDir() and FIleExtension() functions not working in my QVW.

Hello there


I'm trying a subroutine to enlist all files in a directory based on a couple of extensions. My load script is pretty simple (took it from Qlik help):

sub DoDir (Path)

For Each Ext in 'qvw', 'qvo', 'qvs', 'qvt', 'qvd', 'qvc'

For Each File in filelist (Path&'\*.' &Ext)

LOAD

'$(File)' as Name,

FileSize( '$(File)' ) as Size,

FileTime( '$(File)' ) as FileTime,

FileDir( '$(File)' ) as Directory,

FileName( '$(File)' ) as FileNm,

FileExtension( '$(File)' ) as Extension

autogenerate 1;

Next File

Next Ext

For Each Dir in dirlist (Path&'\*' )

Call DoDir (Dir)

Next Dir

End Sub

Call DoDir ('D:\#1Benazir\Qlik')

I get the following table

File functions not working.PNG

Why are three of the functions not returning any values?

Rgds,

Benazir

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Only FileTime() accepts an optional filepath. The other functions do not take a filepath, they are applied to the file being loaded in a load statement. Replace your load with something like this

First 1 LOAD

     '$(File)' as Name,

     FileTime() as FileTime,

     FileSize() as Size,

     FileDir() as Directory,

     FileName() as FileNm

     FileExtension() as Extension

FROM [$(File)] (.....)

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

View solution in original post

5 Replies
micheledenardi
Specialist II
Specialist II

You cannot use FileName(), FileDir() and FileExtension() with autogenerate because these functions supports only folder data connection in standard mode.

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
jonathandienst
Partner - Champion III
Partner - Champion III

Only FileTime() accepts an optional filepath. The other functions do not take a filepath, they are applied to the file being loaded in a load statement. Replace your load with something like this

First 1 LOAD

     '$(File)' as Name,

     FileTime() as FileTime,

     FileSize() as Size,

     FileDir() as Directory,

     FileName() as FileNm

     FileExtension() as Extension

FROM [$(File)] (.....)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Anonymous
Not applicable
Author

Thank you so much Michele and Jonathan!

Anonymous
Not applicable
Author

What do you mean by standard mode?

micheledenardi
Specialist II
Specialist II

It means to use DataConnection in the script and not relative or absolute path.

Refer to the below link for details:

https://help.qlik.com/en-US/sense/February2018/Subsystems/Hub/Content/LoadData/file-system-access-re...

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.