Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
vchuprina
Specialist
Specialist

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?

Press LIKE if the given solution helps to solve the problem.
If it's possible please mark correct answers as "solutions" (you can mark up to 3 "solutions").
4 Replies
danieloberbilli
Specialist II
Specialist II

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
Partner - Specialist III
Partner - Specialist III

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
Partner - Specialist III
Partner - Specialist III

or this one:

Load *, fileextension( ) as X from

C:\UserFiles\abc.txt

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

jpenuliar
Partner - Specialist III
Partner - Specialist III

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