Reputation: 1699
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
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