Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I searched for work around, how to extract html reports from .zip file, however I couldn't find effective solution yet!
I have created a batch script that exctract the html file from .zip file and then rename it as same as .zip file name and lastly delete the .zip file
@Echo off
for /F %%I IN ('dir /b *.zip') DO (
del "%%~nI.html"
"C:\Program Files\7-Zip\7z.exe" x -o"%%~dpI" "%%I" -aoa
for /F "delims=" %%f in ('dir /b *.Html') do (
ren "%%f" "%%~nI.html"
::del "%%~nI.zip"
)
)
however this script is some cases fails.
if another one has a work around that fix this issue please share with me.
Thanks
Hi,
There are some examples online to solve the issue of uncompressing all zipped files of a folder. For example googling I found https://stackoverflow.com/questions/17077964/windows-batch-script-to-unzip-files-in-a-directory (I have not tested it).
You can deliver all Qlik NPrinting HTML reports to a single folder and test one of the batch scripts you can freely find online. In case of issues with the batch script you can generate the reports again by manually running the publish task.
At the moment (latest release is May 2021 SR4) there is not an option to export HTML unzipped from Qlik NPrinting. HTML reports are always delivered zipped https://help.qlik.com/en-US/nprinting/February2021/Content/NPrinting/DistributionSchedulesAutomation...
Best Regards,
Ruggero
I have created a C# console program that do the job in very efficient way, even has a better performance from my above batch script.
i'm sharing it here in case anyone face this problem, can use this code:
*** envControl is text file path that contains the directories you want to perform extracting html from .zip operation. write every directory path in a separate line.
string envControl = @"C:\text.txt"
public void Unzip()
{
using (StreamReader sr = File.OpenText(envControl))
{
string s = String.Empty;
while ((s = sr.ReadLine()) != null)
{
string extractPath = s;
//+++++++++++++++++++++++++++++++++++++++++
string fileNameToDetele = "";
string[] files =
Directory.GetFiles(extractPath, "*.zip", SearchOption.TopDirectoryOnly);
foreach (var item in files)
{
fileNameToDetele = Path.GetFileNameWithoutExtension(item) + ".html";
if (File.Exists(extractPath + fileNameToDetele))
{
File.Delete(extractPath + fileNameToDetele);
}
RenameZipEntries(item);
System.IO.Compression.ZipFile.ExtractToDirectory(item, extractPath);
if (File.Exists(item))
{
File.Delete(item);
}
}
//+++++++++++++++++++++++++++++++++++++++++
}
}
}
private static void RenameZipEntries(string file)
{
using (var archive = new ZipArchive(File.Open(file, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update))
{
var entries = archive.Entries.ToArray();
foreach (var entry in entries)
{
var newEntry = archive.CreateEntry(Path.GetFileNameWithoutExtension(file) + ".html");
using (var a = entry.Open())
using (var b = newEntry.Open())
a.CopyTo(b);
entry.Delete();
}
}
}
Hi,
There are some examples online to solve the issue of uncompressing all zipped files of a folder. For example googling I found https://stackoverflow.com/questions/17077964/windows-batch-script-to-unzip-files-in-a-directory (I have not tested it).
You can deliver all Qlik NPrinting HTML reports to a single folder and test one of the batch scripts you can freely find online. In case of issues with the batch script you can generate the reports again by manually running the publish task.
At the moment (latest release is May 2021 SR4) there is not an option to export HTML unzipped from Qlik NPrinting. HTML reports are always delivered zipped https://help.qlik.com/en-US/nprinting/February2021/Content/NPrinting/DistributionSchedulesAutomation...
Best Regards,
Ruggero
I have created a C# console program that do the job in very efficient way, even has a better performance from my above batch script.
i'm sharing it here in case anyone face this problem, can use this code:
*** envControl is text file path that contains the directories you want to perform extracting html from .zip operation. write every directory path in a separate line.
string envControl = @"C:\text.txt"
public void Unzip()
{
using (StreamReader sr = File.OpenText(envControl))
{
string s = String.Empty;
while ((s = sr.ReadLine()) != null)
{
string extractPath = s;
//+++++++++++++++++++++++++++++++++++++++++
string fileNameToDetele = "";
string[] files =
Directory.GetFiles(extractPath, "*.zip", SearchOption.TopDirectoryOnly);
foreach (var item in files)
{
fileNameToDetele = Path.GetFileNameWithoutExtension(item) + ".html";
if (File.Exists(extractPath + fileNameToDetele))
{
File.Delete(extractPath + fileNameToDetele);
}
RenameZipEntries(item);
System.IO.Compression.ZipFile.ExtractToDirectory(item, extractPath);
if (File.Exists(item))
{
File.Delete(item);
}
}
//+++++++++++++++++++++++++++++++++++++++++
}
}
}
private static void RenameZipEntries(string file)
{
using (var archive = new ZipArchive(File.Open(file, FileMode.Open, FileAccess.ReadWrite), ZipArchiveMode.Update))
{
var entries = archive.Entries.ToArray();
foreach (var entry in entries)
{
var newEntry = archive.CreateEntry(Path.GetFileNameWithoutExtension(file) + ".html");
using (var a = entry.Open())
using (var b = newEntry.Open())
a.CopyTo(b);
entry.Delete();
}
}
}