val
val

Reputation: 1699

In powershell using imagemagick, how to convert image to a new path

I want to convert the tif into jpg that is placed in C:\Data\

Get-ChildItem -Path $source -filter *.tif | %{ convert $_.FullName "C:\Data\$($_.FullName -Replace ".tif+$", ".jpg")" }

But it does not work.

However this works - it places the converted file in the same location as the original file

Get-ChildItem -Path $source -filter *.tif | %{ convert $_.FullName "$($_.FullName -Replace ".tif+$", ".jpg")" }

Upvotes: 1

Views: 1192

Answers (1)

Nick Kavadias
Nick Kavadias

Reputation: 7338

you're messing up the destination path by concatting C:\data with $_.FullName try just the $_.Name property:

Get-ChildItem -Path $source -filter *.tif | %{ convert $_.FullName "C:\Data\$($_.Name -Replace ".tif+$", ".jpg")" }

Upvotes: 1

Related Questions