Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need to loop a table (as for example for each), I have to store the name of the files in a table and I need to create folders with file names;
sub DoDir (Root)
for each Ext in 'qvd'
for each File in filelist (Root&'\*.' &Ext)
set v=FilePath();
LOAD
'$(File)' as Name,
FileSize( '$(File)' ) as Size,
FileTime( '$(File)' ) as FileTime,
Mid('$(File)',21) as dossierecap,
Mid(Mid('$(File)',21),index(Mid('$(File)',21),'\')+1 ) as namefile,
mid(Mid('$(File)',21),Len('DONNEES_RECAP')+1,3 )as Month
autogenerate 1;
next File
next Ext
for each Dir in dirlist (Root&'\*' )
call DoDir (Dir)
next Dir
end sub
call DoDir ('C:\pfe\qlikview\qvd');
So I have to create the files under name 'C:\pfe\qlikview\qvd' & namefile & Month
May be create again two more for each loop for name and month then use same in File to extend and club
i have to use the cmd
Execute cmd.exe /C mkdir C:\pfe\qlikview\qvd & namefile & Month;
with this script i cant
In the Tools/EditModule Script create a function
================================
Function CreateDir(strDirectory)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
End Function
In the load Script
================================
Let Create= CreateDir('c:\CreateDir');
Good Morning Piet,
I understood the first part, that the function Create Dir is used to create a folder by the strDirectory path, but still I do not understand how to put the function in load script
Hi Souad,
Your requirement is not clear enough. Try this and let me know. If this is not you want please elaborate your requirement a bit.
Sub DoDir (Root)
for each Ext in 'qvd'
for each File in filelist (Root&'\*.' &Ext)
set vPath = 'C:\pfe\qlikview\qvd';
Data:
LOAD
'$(File)' as Name,
FileSize( '$(File)' ) as Size,
FileTime( '$(File)' ) as FileTime,
Mid('$(File)',21) as dossierecap,
Mid(Mid('$(File)',21),index(Mid('$(File)',21),'\')+1 ) as namefile,
mid(Mid('$(File)',21),Len('DONNEES_RECAP')+1,3 )as Month
autogenerate 1;
next File
next Ext
//================================================================
Let vnamefile = Peek('namefile');
Let vMonth = Peek('Month');
Execute cmd.exe /C mkdir $(vPath)\$(vnamefile)$(vMonth) ;
Store Data into $(vPath)\$(vnamefile)$(vMonth)\$(vnamefile).qvd (qvd);
DROP Table Data;
//================================================================
If Not $(vPath)\$(vnamefile)$(vMonth) then
for each Dir in dirlist (Root&'\*' )
call DoDir (Dir)
next Dir
End If
end sub
call DoDir ('C:\pfe\qlikview\qvd');
The function is not in the load script but in the macro editor, from the qlikview menu Tools/Edit module
And then in the load script