Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
is there a way to check if a directory exists? and if it doens't exist create the directory?
thanks in advance 🙂
Rey-man
How about this one?
if FileTime('C:\Test') > 0 then
Set vDirExists = 'Yes';
else
Set vDirExists = 'No';
end if
Try this:
sub createFolder
newfolder = "E:\QVApplications\QVTest\newone"
set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(newfolder) Then
Set newfolder = fso.CreateFolder(newfolder)
End If
end sub
Regards,
Gordon
Hi Gordon,
its not working the way it want it i guess. This looks like a macro. I want it in the load script.
I fill in the tablename and description manually. Based on the name, it should create the directory. (see LET vDir)
LET vDir = 'D:\QlikView Storage\Private Data\Source Documents\Data\SAP ECC\$(vNaam)\';
SET fso = CreateObject("Scripting.FileSystemObject")
IF NOT fso.FolderExists('$(vDir)') THEN
SET newfolder = fso.CreateFolder('$(vDir)')
'$(vNaam)':
LOAD
*
;
SQL SELECT *
FROM $(vNaam)
;
//STORE $(vNaam) INTO ../Data/SAP ECC/New/$(vDesc)$(vQVD_ECC_version)$(vVersionNumber)$(vWeek)$(Year).qvd;
STORE $(vNaam) INTO $(vDir)$(vNaam)_$(vDesc)$(vQVD_ECC_version)$(vVersionNumber)$(vWeek)$(Year).qvd;
DROP TABLE $(vNaam);
End If
Hope its clear what im trying to say.
Regards,
Rey-man
You can create the function in your macro and execute the function during the script reload
LET CreateFolder = CreateFolder();
//Where CreateFolder is the macro function
This way the macro will be launched only during reload of application
.
Rgds,
Sébastien
Hi Sébastien,
i don't want to use a macro if its not necessary.
Is there a way to avoid this? or is it the only option?
Rgds,
Rey-man
I don't think about another way...
Here is another option for you.
Use this is your QV script:
Let vTime = FileTime('C:\Test');
In abopve line "Test" is a directory in "C" drive. If vTime is empty, directory doesn't exists. 🙂
I was surprised to see that this file function works on directories as well, atleast on my machine. Please validate if it works on your machine as well.
Hi Rakesh,
I tested it, but of course, if the directory doesn't exists, the variable vTime neither exists.
So how can I create an if function then, cause the compiler returns an error in the script. Its says IF '' = '' then ...
Regards
Rey-man
How about this one?
if FileTime('C:\Test') > 0 then
Set vDirExists = 'Yes';
else
Set vDirExists = 'No';
end if
Now the only part remains the creation of this directory itself.
Greetz
Rey-man