Display Current operation

83 views Asked by At

I have around 14 GB of photos that need to be compressed. I use an application mogrify.

Which so far I can do what I require that is compress the image by 50% using this one liner.

mogrify -quality 50% *.jpg

Now, that only works in the current folder, so I put together a very simple PS version:

Get-ChildItem E:\PHOTOGRAPHS -Include *.jpg -Recurse | foreach ($_) {
  mogrify -quality 50% $_.FullName
}

What I would like is the current filename to be displayed with path, but am struggling to be able to do it.

2

There are 2 answers

0
Ansgar Wiechers On BEST ANSWER

Simply echo the full name of the file inside the ForEach-Object loop:

Get-ChildItem E:\PHOTOGRAPHS -Include *.jpg -Recurse | ForEach-Object {
  $_.FullName
  mogrify -quality 50% $_.FullName
}
2
TheMadTechnician On

I've always been a fan of Write-Progress myself...

Get-ChildItem E:\PHOTOGRAPHS -Include *.jpg -Recurse | foreach ($_) {
    Write-Progress $_.FullName
    mogrify -quality 50% $_.FullName
}

No screen scroll with that, and I guess it doesn't give you a list to track, but it seems clean to me.