ProgressBar for Zip arhive in powershell
I have a piece of code that works just fine in powershell.
However I want to visualize the amount of work (zipping process).
Write-Host "Started zipping files and folders..." -ForegroundColor Yellow
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
$zip = [System.IO.Compression.ZipFile]::CreateFromDirectory("$Destination$folderName",
"$Destination$folderName.zip", $compressionLevel, $false)
if ($?) {
Write-Host "Zip process success. Exiting..." -ForegroundColor Yellow
Invoke-Item "$Destination"
sleep -Seconds 2
}
else {
Write-Host "Zip process failed." -ForegroundColor Red
}
I assume that what I need to put is something like:
Write-Progress -Activity "Zipping files and folders..." -Status "Progress:" -PercentComplete ($zip/something?)}
I am using Powershell v 5.1
UPDATE:
I will probably change and use incorporated cmdlet Compress-Archive
powershell
add a comment |
I have a piece of code that works just fine in powershell.
However I want to visualize the amount of work (zipping process).
Write-Host "Started zipping files and folders..." -ForegroundColor Yellow
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
$zip = [System.IO.Compression.ZipFile]::CreateFromDirectory("$Destination$folderName",
"$Destination$folderName.zip", $compressionLevel, $false)
if ($?) {
Write-Host "Zip process success. Exiting..." -ForegroundColor Yellow
Invoke-Item "$Destination"
sleep -Seconds 2
}
else {
Write-Host "Zip process failed." -ForegroundColor Red
}
I assume that what I need to put is something like:
Write-Progress -Activity "Zipping files and folders..." -Status "Progress:" -PercentComplete ($zip/something?)}
I am using Powershell v 5.1
UPDATE:
I will probably change and use incorporated cmdlet Compress-Archive
powershell
add a comment |
I have a piece of code that works just fine in powershell.
However I want to visualize the amount of work (zipping process).
Write-Host "Started zipping files and folders..." -ForegroundColor Yellow
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
$zip = [System.IO.Compression.ZipFile]::CreateFromDirectory("$Destination$folderName",
"$Destination$folderName.zip", $compressionLevel, $false)
if ($?) {
Write-Host "Zip process success. Exiting..." -ForegroundColor Yellow
Invoke-Item "$Destination"
sleep -Seconds 2
}
else {
Write-Host "Zip process failed." -ForegroundColor Red
}
I assume that what I need to put is something like:
Write-Progress -Activity "Zipping files and folders..." -Status "Progress:" -PercentComplete ($zip/something?)}
I am using Powershell v 5.1
UPDATE:
I will probably change and use incorporated cmdlet Compress-Archive
powershell
I have a piece of code that works just fine in powershell.
However I want to visualize the amount of work (zipping process).
Write-Host "Started zipping files and folders..." -ForegroundColor Yellow
Add-Type -Assembly System.IO.Compression.FileSystem
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
$zip = [System.IO.Compression.ZipFile]::CreateFromDirectory("$Destination$folderName",
"$Destination$folderName.zip", $compressionLevel, $false)
if ($?) {
Write-Host "Zip process success. Exiting..." -ForegroundColor Yellow
Invoke-Item "$Destination"
sleep -Seconds 2
}
else {
Write-Host "Zip process failed." -ForegroundColor Red
}
I assume that what I need to put is something like:
Write-Progress -Activity "Zipping files and folders..." -Status "Progress:" -PercentComplete ($zip/something?)}
I am using Powershell v 5.1
UPDATE:
I will probably change and use incorporated cmdlet Compress-Archive
powershell
powershell
edited Nov 20 '18 at 10:42
Stefan0309
asked Nov 20 '18 at 10:37
Stefan0309Stefan0309
359422
359422
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If you use Compress-Archive it will do what you want and show a progress bar.
Compress-Archive -Path "$Destination$folderName" -DestinationPath "$Destination$folderName.zip"
hey, thanks! I've just updated my question. 3 minutes ago I crossed on thic cmdlet. But How can I do that? can you write some link with Compress-Archive and Write-Progress?
– Stefan0309
Nov 20 '18 at 10:43
You don't specifically need to use Write-Progress, the progress bar is native.
– James C.
Nov 20 '18 at 10:45
I've just run it a Compress-Archive cmdlet, and I don't see any progress bar. Maybe because I am working VSCode environment for development? Thanks Update: exactly what I said - in VSCode I can't see progressbar, while when I run it through powershell.exe I see it. Thanks
– Stefan0309
Nov 20 '18 at 10:47
Not sure on VSCode, but it doesn't show progress if you're compressing a small archive. It will show like i.stack.imgur.com/37JuN.png on a big archive (ignore nodejs ref it's a random screenshot from google to illustrate)
– James C.
Nov 20 '18 at 10:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391128%2fprogressbar-for-zip-arhive-in-powershell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you use Compress-Archive it will do what you want and show a progress bar.
Compress-Archive -Path "$Destination$folderName" -DestinationPath "$Destination$folderName.zip"
hey, thanks! I've just updated my question. 3 minutes ago I crossed on thic cmdlet. But How can I do that? can you write some link with Compress-Archive and Write-Progress?
– Stefan0309
Nov 20 '18 at 10:43
You don't specifically need to use Write-Progress, the progress bar is native.
– James C.
Nov 20 '18 at 10:45
I've just run it a Compress-Archive cmdlet, and I don't see any progress bar. Maybe because I am working VSCode environment for development? Thanks Update: exactly what I said - in VSCode I can't see progressbar, while when I run it through powershell.exe I see it. Thanks
– Stefan0309
Nov 20 '18 at 10:47
Not sure on VSCode, but it doesn't show progress if you're compressing a small archive. It will show like i.stack.imgur.com/37JuN.png on a big archive (ignore nodejs ref it's a random screenshot from google to illustrate)
– James C.
Nov 20 '18 at 10:50
add a comment |
If you use Compress-Archive it will do what you want and show a progress bar.
Compress-Archive -Path "$Destination$folderName" -DestinationPath "$Destination$folderName.zip"
hey, thanks! I've just updated my question. 3 minutes ago I crossed on thic cmdlet. But How can I do that? can you write some link with Compress-Archive and Write-Progress?
– Stefan0309
Nov 20 '18 at 10:43
You don't specifically need to use Write-Progress, the progress bar is native.
– James C.
Nov 20 '18 at 10:45
I've just run it a Compress-Archive cmdlet, and I don't see any progress bar. Maybe because I am working VSCode environment for development? Thanks Update: exactly what I said - in VSCode I can't see progressbar, while when I run it through powershell.exe I see it. Thanks
– Stefan0309
Nov 20 '18 at 10:47
Not sure on VSCode, but it doesn't show progress if you're compressing a small archive. It will show like i.stack.imgur.com/37JuN.png on a big archive (ignore nodejs ref it's a random screenshot from google to illustrate)
– James C.
Nov 20 '18 at 10:50
add a comment |
If you use Compress-Archive it will do what you want and show a progress bar.
Compress-Archive -Path "$Destination$folderName" -DestinationPath "$Destination$folderName.zip"
If you use Compress-Archive it will do what you want and show a progress bar.
Compress-Archive -Path "$Destination$folderName" -DestinationPath "$Destination$folderName.zip"
edited Nov 20 '18 at 10:43
answered Nov 20 '18 at 10:41
James C.James C.
8,49722030
8,49722030
hey, thanks! I've just updated my question. 3 minutes ago I crossed on thic cmdlet. But How can I do that? can you write some link with Compress-Archive and Write-Progress?
– Stefan0309
Nov 20 '18 at 10:43
You don't specifically need to use Write-Progress, the progress bar is native.
– James C.
Nov 20 '18 at 10:45
I've just run it a Compress-Archive cmdlet, and I don't see any progress bar. Maybe because I am working VSCode environment for development? Thanks Update: exactly what I said - in VSCode I can't see progressbar, while when I run it through powershell.exe I see it. Thanks
– Stefan0309
Nov 20 '18 at 10:47
Not sure on VSCode, but it doesn't show progress if you're compressing a small archive. It will show like i.stack.imgur.com/37JuN.png on a big archive (ignore nodejs ref it's a random screenshot from google to illustrate)
– James C.
Nov 20 '18 at 10:50
add a comment |
hey, thanks! I've just updated my question. 3 minutes ago I crossed on thic cmdlet. But How can I do that? can you write some link with Compress-Archive and Write-Progress?
– Stefan0309
Nov 20 '18 at 10:43
You don't specifically need to use Write-Progress, the progress bar is native.
– James C.
Nov 20 '18 at 10:45
I've just run it a Compress-Archive cmdlet, and I don't see any progress bar. Maybe because I am working VSCode environment for development? Thanks Update: exactly what I said - in VSCode I can't see progressbar, while when I run it through powershell.exe I see it. Thanks
– Stefan0309
Nov 20 '18 at 10:47
Not sure on VSCode, but it doesn't show progress if you're compressing a small archive. It will show like i.stack.imgur.com/37JuN.png on a big archive (ignore nodejs ref it's a random screenshot from google to illustrate)
– James C.
Nov 20 '18 at 10:50
hey, thanks! I've just updated my question. 3 minutes ago I crossed on thic cmdlet. But How can I do that? can you write some link with Compress-Archive and Write-Progress?
– Stefan0309
Nov 20 '18 at 10:43
hey, thanks! I've just updated my question. 3 minutes ago I crossed on thic cmdlet. But How can I do that? can you write some link with Compress-Archive and Write-Progress?
– Stefan0309
Nov 20 '18 at 10:43
You don't specifically need to use Write-Progress, the progress bar is native.
– James C.
Nov 20 '18 at 10:45
You don't specifically need to use Write-Progress, the progress bar is native.
– James C.
Nov 20 '18 at 10:45
I've just run it a Compress-Archive cmdlet, and I don't see any progress bar. Maybe because I am working VSCode environment for development? Thanks Update: exactly what I said - in VSCode I can't see progressbar, while when I run it through powershell.exe I see it. Thanks
– Stefan0309
Nov 20 '18 at 10:47
I've just run it a Compress-Archive cmdlet, and I don't see any progress bar. Maybe because I am working VSCode environment for development? Thanks Update: exactly what I said - in VSCode I can't see progressbar, while when I run it through powershell.exe I see it. Thanks
– Stefan0309
Nov 20 '18 at 10:47
Not sure on VSCode, but it doesn't show progress if you're compressing a small archive. It will show like i.stack.imgur.com/37JuN.png on a big archive (ignore nodejs ref it's a random screenshot from google to illustrate)
– James C.
Nov 20 '18 at 10:50
Not sure on VSCode, but it doesn't show progress if you're compressing a small archive. It will show like i.stack.imgur.com/37JuN.png on a big archive (ignore nodejs ref it's a random screenshot from google to illustrate)
– James C.
Nov 20 '18 at 10:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53391128%2fprogressbar-for-zip-arhive-in-powershell%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown