Renaming files by reformatting existing filenames - placeholders in replacement strings used with the -replace operator

后端 未结 4 1132
醉话见心
醉话见心 2020-11-21 22:23

I have a few video file like this: VideoName_s01e01.mp4 where the season and episodes are variables. I want to add an underscore (\"_\") between the s??

4条回答
  •  野性不改
    2020-11-21 22:44

    I highly recommend regex101.com for learning regex.

    Something like this can work:

    "VideoName_s01e01.mp4" -replace '(.*s)(\d+)(e.*)', '$1$2_$3'
    

    Gives:

    VideoName_s01_e01.mp4
    

提交回复
热议问题