Increase the existing number in a file name by one

Bulk Rename Utility How-To's

Increase the existing number in a file name by one

Postby Admin » Mon Sep 01, 2025 6:55 am

To increase the existing number in a filename by one using Bulk Rename Utility, you can use the Name (2) - Fixed field with a renaming tag and formatting (version 4.1.0.0 or newer):

1. In the Name (2) section, select "Fixed".
2. Use this tag with formatters to find the first number, add 1, and keep the rest of the name:

```
<name{slicenum}{math:+1}{pad0:0}>
```

Explanation:
- `<name>` is the current filename without extension.
- `{slicenum}` focuses on the first number in the name.
- `{math:+1}` adds 1 to that number.
- `{pad0:0}` keeps the number length as is (no padding).

This will increment the first number found in the filename by 1.

Example:
- Original: `file7.txt`
- Result: `file8.txt`

If you want to pad the number with zeros to 3 digits, use `{pad0:3}` instead.

---------------------------------------------------------------------------------------------------------

In Bulk Rename Utility, formatters let you modify tag values before inserting them into filenames. Here are explanations and examples for the math and pad formatters:

---

### 1. math — Perform arithmetic on numbers

- Purpose: Add, subtract, multiply, divide, or raise to a power a numeric value.
- Syntax:
`{math:+K}` or `{math:add:K}` — add K
`{math:-K}` or `{math:sub:K}` — subtract K
`{math:*K}` or `{math:mul:K}` — multiply by K
`{math:/K}` or `{math:div:K}` — divide by K (integer division, truncates)
`{math:^K}` or `{math:pow:K}` — raise to power K (K > 0)

- Examples:
- `<name{slicenum}{math:+1}{pad0:3}>`
If filename is "Scene-002", `slicenum` extracts "002"- > add 1 -> 3 -> pad0 to 3 digits -> "003"
Result: "Scene-003"
- `<(System.Media.Year){math:+1}>`
If year is 2024, adds 1 -> "2025"

---

### 2. pad — Left-pad text to a specified width with a character

- Purpose: Pad the text on the left to a minimum width using a specified character (default is space if not specified).
- Syntax:
`{pad:width[:char]}`
- `width` = total length after padding
- `char` = optional padding character (single character)

- Examples:
- `"7"{pad:3:0}` -> `"007"`
- `"A"{pad:3:_}` -> `"__A"`
- `<(counter){pad0:4}>` zero-pads a number to 4 digits, e.g., 23 -> "0023"

---

### Combining math and pad

You can combine them to manipulate numbers and format them nicely:

Example:
`<name{slicenum}{math:+10}{pad0:4}>`
- Finds first number in name, adds 10, then zero-pads to 4 digits.
- "build_23_alpha" -> number 23 + 10 = 33 -> "0033" -> "build_0033_alpha"

---

Summary:
- Use `{math:...}` to do arithmetic on numbers extracted from tags.
- Use `{pad:width[:char]}` to left-pad the resulting text to a fixed width with a chosen character.
- `{pad0:width}` is a shortcut to zero-pad numbers preserving sign.

These formatters help you customize numeric parts of filenames precisely during batch renaming.
Admin
Site Admin
 
Posts: 3054
Joined: Tue Mar 08, 2005 8:39 pm

Return to How-To