- Aug
- 42
- 2
I have a folder containing files generated by screen captures. The files are named ImageN.jpg and imageNN.jpg, where N is of course a digit. I want to rename all the ImageN.jpg files to Image0N.jpg and leave the ImageNN.jpg files alone. I have tried and tried to do this with no success. However I structure the regexes, I either get no rename or I get all the files renamed. Here are examples.
Note that if I use the first regex in a dir command, I get only the 1-digit files:
If someone could please tell me what I'm doing wrong I would greatly appreciate it. It's probably something simple, but I just can't see it. Thank you.
Code:
> ren "::image(\d).jpg" ::"image0\1.jpg"
Image1.jpg -> Image1.jpg
Image2.jpg -> Image2.jpg
Image3.jpg -> Image3.jpg
Image5.jpg -> Image5.jpg
Image7.jpg -> Image7.jpg
Image8.jpg -> Image8.jpg
Image9.jpg -> Image9.jpg
7 files renamed
> ren ::image(\d{1}).jpg ::image0\1.jpg
Image1.jpg -> Image1.jpg
Image2.jpg -> Image2.jpg
Image3.jpg -> Image3.jpg
Image5.jpg -> Image5.jpg
Image7.jpg -> Image7.jpg
Image8.jpg -> Image8.jpg
Image9.jpg -> Image9.jpg
7 files renamed
> ren "::^(.*)(\d{1})\.jpg" ::"\{1}0\2\.jpg"
Image1.jpg -> Image01.jpg
Image10.jpg -> Image100.jpg
Image11.jpg -> Image101.jpg
Image12.jpg -> Image102.jpg
Image13.jpg -> Image103.jpg
Image2.jpg -> Image02.jpg
Image3.jpg -> Image03.jpg
Image5.jpg -> Image05.jpg
Image7.jpg -> Image07.jpg
Image8.jpg -> Image08.jpg
Image9.jpg -> Image09.jpg
11 files renamed
Note that if I use the first regex in a dir command, I get only the 1-digit files:
Code:
> dir/b ::image(\d).jpg
Image9.jpg
Image8.jpg
Image7.jpg
Image5.jpg
Image1.jpg
Image2.jpg
Image3.jpg
If someone could please tell me what I'm doing wrong I would greatly appreciate it. It's probably something simple, but I just can't see it. Thank you.