Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello qlikers,
i have a folder for example C:/Documents/QVD in this folder there are .qvd files.
Now I want to save the .qvd files in the folder C:/Documents/Backup, i also want to create a log file for the backup.
The follow code shows who I create the log file.
// backup the files
Test:
LOAD *
FROM [path]
(qvd);
Store Rating INTO 'path/Test_$(vNow).qvd' (qvd);
DROP TABLE Test;
// log file
LOAD distinct
SubField(FileName(),'.',1) AS FILE_NAME, // the name should the name of the Backup file
Date(Floor(FileTime())) AS DATE,
Time(FileTime()) AS TIME,
Timestamp(now()) as TIMESTAMP
FROM [folder]
(qvd);
My question is, how can I loop the whole folder C:/Documents/QVD and save all .qvd files in the folder C:/Documents/Backup and fill the .csv file with the above-mentioned code (create a log file).
Thank you in advance!
- Steven
You can create something like this:
FOR EACH _file in filelist('lib:/QvdPath/*.qvd');
Load *
From $(_file)
Store ... into ....;
CsvData:
First 1 LOAD
... your file info functions...
FROM
[$(_file)] (qvd)
NEXT _file;
Like this:
for each File in filelist ('lib://C:/Documents/QVD/*.qvd)
your code here;
next File;
I wouldn't load all qvd's again else just copy/move them. This could be done with an EXECUTE statement within a for each loop with filelist() and the loop-variable could be taken to query the various properties of the file, like filetime/filesize and so on (and qvd-files have some more of these features).
For the filelist-loop take a look in the help by for each (there are some good examples and of course many more here in the community) and here an example for execute: EXECUTE-command-to-move-files-listed-in-an-XLSX-or-TXT (whereby in Sense I think you will need to enable the legacy mode for it).
- Marcus