Adeel ASIF
Adeel ASIF

Reputation: 3544

Replace string in powershell array

This is my array :

$array who contains theses values :

Y:\155150716070\00000027.JPG
Y:\155150716070\00000028.JPG
Y:\155150716070\00000029.JPG
Y:\155150716070\00000030.JPG
Y:\155150716070\00000031.JPG
Y:\155150716070\00000032.JPG
Y:\155150716070\00000033.JPG
Y:\155150716070\00000034.JPG
Y:\155150716070\00000035.JPG
Y:\155150716070\00000036.JPG

How can i replace "JPG" by "TIF" to get something like that ?

Y:\155150716070\00000027.TIF
Y:\155150716070\00000028.TIF
Y:\155150716070\00000029.TIF
Y:\155150716070\00000030.TIF
Y:\155150716070\00000031.TIF
Y:\155150716070\00000032.TIF
Y:\155150716070\00000033.TIF
Y:\155150716070\00000034.TIF
Y:\155150716070\00000035.TIF
Y:\155150716070\00000036.TIF

Thanks for your help

Upvotes: 10

Views: 33706

Answers (1)

mjolinor
mjolinor

Reputation: 68341

Using -replace as an array operator:

$array -replace 'JPG$','TIF'

Upvotes: 22

Related Questions