Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Drive Space

Hi guys,

I am new to QV, could you tell script to fetch the CD drive space of a local machine?

Deepti

1 Solution

Accepted Solutions
Gysbert_Wassenaar

First open a command prompt and then execute the command dir c: d: > dirlist.txt. Then open Qlikview and add this to your script:

Data:

LOAD * WHERE len(Drive);

LOAD

  if(SubStringCount(previous(line),'Volume in drive'),mid(previous(line),17,1)) as Drive,

  If(SubStringCount(line,'bytes free'),trim(TextBetween(line, 's) ',' bytes free'))) as BytesFree;

LOAD [@1:n] as line

FROM [dirlist.txt] (fix, codepage is 1252, no labels)

WHERE  SubStringCount([@1:n],'Volume in drive') or  SubStringCount([@1:n],'bytes free')

If you want to be able to execute the command line command from inside Qlikview then you first need to disable some security settings so you can do dangerous things like starting arbitrary programs from Qlikview. One of these setting can be found on the Settings tab of the Script Editor: Can Execute External Programs.


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Gysbert_Wassenaar

Can you explain what you mean with "fetch the CD drive space"?


talk is cheap, supply exceeds demand
maxgro
MVP
MVP

for C drive

Execute cmd.exe /C "dir c: > space.txt";

SPACE:

LOAD @1

FROM

space.txt

(txt, codepage is 1252, explicit labels, delimiter is '\t', msq)

Where @1 like '*byte*';

1.png

Not applicable
Author

Well, I want to Fetch the available space of the C and D drive of a local machine and store it in QVD.

Not applicable
Author

When I tried to execute the "dir c: > space.txt";  in command prompt. I got message saying access denied.

Please explain in detail.

Gysbert_Wassenaar

First open a command prompt and then execute the command dir c: d: > dirlist.txt. Then open Qlikview and add this to your script:

Data:

LOAD * WHERE len(Drive);

LOAD

  if(SubStringCount(previous(line),'Volume in drive'),mid(previous(line),17,1)) as Drive,

  If(SubStringCount(line,'bytes free'),trim(TextBetween(line, 's) ',' bytes free'))) as BytesFree;

LOAD [@1:n] as line

FROM [dirlist.txt] (fix, codepage is 1252, no labels)

WHERE  SubStringCount([@1:n],'Volume in drive') or  SubStringCount([@1:n],'bytes free')

If you want to be able to execute the command line command from inside Qlikview then you first need to disable some security settings so you can do dangerous things like starting arbitrary programs from Qlikview. One of these setting can be found on the Settings tab of the Script Editor: Can Execute External Programs.


talk is cheap, supply exceeds demand