Adding number based on a condition
#1 : 26/07-25 20:31 Adrian
Posts: 3
|
Hello,
I want to add 0 at the position 1 backwards to every file name that ends with a number. Otherwise add 00 to the name. For instance: file 1.txt -> file 01.txt file.txt -> file 00.txt file 2.txt -> file 02.txt Can this be done without JavaScript? |
#2 : 26/07-25 21:06 Delta Foxtrot
Posts: 535
|
Reply to #1:
Hi Adrian, Sure, you can do it in two steps: 1) RENUMBER method: Number position: 1 Change to: Relative to existing number Number difference: 0 Zero padding: Manual Number length: 2 Apply to: Name 2) REPLACE method: Replace: ^([a-z]+)$ Replace with: $1 00 Occurrence: All or 1st Case sens.: NO Use regular expressions: YES Apply to: Name The first just pads numbers already there. The second adds <space>00 only if there is no number at the end of the filename. Best, DF |