简体   繁体   中英

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

使用-replace作为数组运算符:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM