I am currently utilizing PowerRename, a tool that allows for regex usage to select portions of filenames for replacement. My goal is to tidy up some filenames by removing the preceding zeroes before a number in the file name (replacing them with nothing).
Below are examples of file names, corresponding patterns for matching, and previews generated by PowerRename after replacing the matched strings:
filename -> matching string -> renamed file
00000.jpg -> "0000" -> 0.jpg
00001.jpg -> "0000" -> 1.jpg
00010.jpg -> "000" -> 10.jpg
00011.jpg -> "000" -> 11.jpg
00100.jpg -> "00" -> 100.jpg
00101.jpg -> "00" -> 101.jpg
00219.jpg -> "00" -> 219.jpg
01000.jpg -> "0" -> 1000.jpg
12345.jpg -> "" -> 12345.jpg
img.00002.jpg -> "0000" -> img.2.jpg
Which regex pattern should I utilize to achieve this desired outcome? I have labeled it as .NET because that's the regex documentation I was directed to while using the app.
I have experimented with different combinations but the closest match I achieved was [0]{2}, which correctly handles single-digit numbers but fails with two or more digit numbers containing multiple zeroes (20, 100, etc.)
Illustrated below is the result when using the pattern [0]{2}:
filename -> renamed file
00000.jpg -> 0.jpg
00001.jpg -> 1.jpg
00010.jpg -> 010.jpg
00011.jpg -> 011.jpg
00100.jpg -> 1.jpg
00101.jpg -> 101.jpg
00219.jpg -> 219.jpg
01000.jpg -> 010.jpg
12345.jpg -> 12345.jpg
image.00002.jpg -> image.2.jpg
I also tested [^0][0-9]*, which omits zeroes and only functions well if the filename (excluding extension) comprises solely of numbers:
filename -> renamed file
00000.jpg -> 00000
00001.jpg -> 0000
00010.jpg -> 000
00011.jpg -> 000
00100.jpg -> 00
00101.jpg -> 00
00219.jpg -> 00
01000.jpg -> 0
12345.jpg ->
image.00002.jpg ->