How to limit filenames to a maximum length
Case: You want to shorten long filenames to a maximum length while keeping shorter filenames unchanged.
Advanced Renamer can keep the first part of each filename and remove any characters beyond your chosen limit. This is useful when preparing files for a system that only accepts short names. You can do this with either the New Name method or the Remove method.
The examples below limit the name to 20 characters, excluding the extension. The extension, such as .jpg or .docx, is kept unchanged. Spaces, numbers, and punctuation in the name all count towards the limit.
| Original filename | New filename |
|---|---|
Summer_holiday_photo_001.jpg | Summer_holiday_photo.jpg |
Project_report_draft_v2.docx | Project_report_draft.docx |
Notes.txt | Notes.txt |
Solution 1: Keep the first characters with New Name
The Substr tag copies a part of the filename. Starting at position 1 and copying up to 20 characters gives a name with a maximum of 20 characters. If the name is already shorter, the whole name is kept without adding any characters.
- Add the files to the list.
- If there are methods in the method list, click the Clear Methods toolbar button.
- Add the New Name method and configure it like this:
- New name:
<Substr:1:20> - Apply To: Name
- New name:
- Verify the new names in the list and click Start Batch.
Replace 20 with your desired maximum. For example, use <Substr:1:50> to keep up to 50 characters. With Apply To set to Name, the extension is preserved automatically, so you do not need to add an extension tag.
Solution 2: Remove everything after the limit
The Remove method can delete characters starting immediately after the last character you want to keep. To keep 20 characters, start removing at position 21.
- Add the files to the list.
- If there are methods in the method list, click the Clear Methods toolbar button.
- Add the Remove method and configure it like this:
- Remove type: Position
- Starting at:
21 - Count:
9999 - Backwards: Unchecked
- Use regular expressions: Unchecked
- Apply To: Name
- Verify the new names in the list and click Start Batch.
Count is the number of characters to remove, rather than the length to keep. Use a value large enough to remove the rest of your longest name, such as 9999. If fewer characters remain, only those characters are removed. Names with 20 characters or fewer are unchanged. For another limit, set Starting at to the maximum length plus 1. For example, use 51 to keep up to 50 characters.