Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

vchuprina
New Contributor III

How determine file extension?

I receive files with different extension and for this reason I should manually resave a lot of files in nessecerary extension.

How can determine this using qlikview?

4 Replies
danieloberbilli
Valued Contributor II

Re: How determine file extension?

You could write a batch file that deals with managing the files.

You can run the batch file in the qlik script run by e.g.

EXECUTE CMD /C D:\...\MyBatchFile.bat;

jpenuliar
Valued Contributor III

Re: How determine file extension?

you could probably do a code like below:

// 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:')

jpenuliar
Valued Contributor III

Re: How determine file extension?

or this one:

Load *, fileextension( ) as X from

C:\UserFiles\abc.txt

Will return 'txt' in field X in each record read.

jpenuliar
Valued Contributor III

Re: How determine file extension?

This one works,

LET vfile_Path = 'C:\Users\jpenuliar\Desktop\Reports Management\files here\';

Sub GetFilesInFolder(Root)

For Each File in FileList(Root & '*.*')
[Production Reports Table]:
Load
'$(File)'
as File_Name,
subfield('$(File)', '.', -1) as FileExtension,
FileSize('$(File)') as Size,
FileTime('$(File)') as File_Time
AutoGenerate 1;

Next File

End Sub

Call GetFilesInFolder('$(vfile_Path)')

Community Browser