Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 935
Adeel ASIF Avatar asked Aug 06 '15 21:08

Adeel ASIF


1 Answers

Using -replace as an array operator:

$array -replace 'JPG$','TIF'
like image 145
mjolinor Avatar answered Oct 14 '22 03:10

mjolinor