Advanced Renamer .aren technical reference for LLMs

Markdown source · Complete reference (text) · JSON Schema

Advanced Renamer .aren worked examples

Each example pairs a request with a complete .aren project file and expected results. Every file uses "type": "project" and follows the field reference. Application usage is described in the user guide.

Format target: Advanced Renamer 4.29. Files are UTF-8. Inputs are files in the same folder, checked and arranged in the displayed order unless stated otherwise. Expected results assume increment-tag zero padding is enabled and automatic filename character cleanup is disabled. Timestamps use local wall-clock time. These files do not select or sort input items or set these application options.

1. Replace underscores with spaces

Request: Replace underscores with spaces and keep extensions.

File: underscores-to-spaces.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "_",
      "replacewith": " ",
      "casesensitive": false,
      "regularexpressions": false,
      "occurrence": 0
    }
  ]
}
Original filename New filename
summer_holiday.jpg summer holiday.jpg
annual_report.PDF annual report.PDF

2. Add a prefix

Request: Prefix every basename with Archive_.

File: add-prefix.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "add",
      "active": true,
      "applyto": "name",
      "add": "Archive_",
      "position": "1",
      "backwards": false,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
report.pdf Archive_report.pdf
image.JPG Archive_image.JPG

3. Add a suffix before the extension

Request: Append _approved to each basename, keeping the extension.

File: add-suffix.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "add",
      "active": true,
      "applyto": "name",
      "add": "_approved",
      "position": "0",
      "backwards": true,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
report.pdf report_approved.pdf
image.JPG image_approved.JPG

4. Create padded sequential names

Request: Name these files Photo_001, Photo_002, and so on, preserving extensions.

Arrange the files in the required order. Increment-tag zero padding must be enabled; this project file does not set that option.

File: numbered-photos.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newname",
      "active": true,
      "applyto": "name",
      "mask": "Photo_<Inc Nr:001>"
    }
  ]
}
Original filename New filename
DSC100.jpg Photo_001.jpg
DSC200.PNG Photo_002.PNG

5. Set a counter start and step

Request: Use scan_010, scan_012, scan_014 in the displayed order.

The second counter parameter is the step, not a padding width. Increment-tag zero padding must be enabled.

File: counter-step.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newname",
      "active": true,
      "applyto": "name",
      "mask": "scan_<Inc Nr:010:2>"
    }
  ]
}
Original filename New filename
a.tif scan_010.tif
b.tif scan_012.tif
c.tif scan_014.tif

6. Lowercase basenames only

Request: Lowercase the basename, leaving the extension exactly as it is.

File: lowercase-basename.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newcase",
      "active": true,
      "applyto": "name",
      "newcasetype": "lower",
      "newcaselocation": "all",
      "applylowercasefirst": false,
      "ignorewordsallcaps": false
    }
  ]
}
Original filename New filename
Annual_REPORT.PDF annual_report.PDF

7. Lowercase the whole filename

Request: Lowercase filenames including their extensions.

File: lowercase-whole-filename.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newcase",
      "active": true,
      "applyto": "nameandextension",
      "newcasetype": "lower",
      "newcaselocation": "all",
      "applylowercasefirst": false,
      "ignorewordsallcaps": false
    }
  ]
}
Original filename New filename
Annual_REPORT.PDF annual_report.pdf

8. Uppercase extensions only

Request: Uppercase only the extensions.

File: uppercase-extension.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newcase",
      "active": true,
      "applyto": "extension",
      "newcasetype": "upper",
      "newcaselocation": "all",
      "applylowercasefirst": false,
      "ignorewordsallcaps": false
    }
  ]
}
Original filename New filename
annual_report.pdf annual_report.PDF
photo.jpg photo.JPG

9. Normalize JPEG extensions

Request: Change jpg and jpeg extensions to jpg, preserving basename case and leaving other extensions alone.

File: normalize-jpeg-extension.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newname",
      "active": true,
      "applyto": "extension",
      "mask": "jpg",
      "condition": {
        "active": true,
        "field": "ext",
        "match": "equals",
        "pattern": "jpg/jpeg",
        "notmatching": false
      }
    }
  ]
}
Original filename New filename
Portrait.JPEG Portrait.jpg
Snapshot.JPG Snapshot.jpg
Diagram.PNG Diagram.PNG

10. Rearrange a date using regex captures

Request: Convert YYYY-MM-DD_report to DD-MM-YYYY_report, preserving extensions.

File: reorder-date.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "^(\\d{4})-(\\d{2})-(\\d{2})_(.+)$",
      "replacewith": "$3-$2-$1_$4",
      "casesensitive": false,
      "regularexpressions": true,
      "occurrence": 0
    }
  ]
}
Original filename New filename
2026-11-06_report.txt 06-11-2026_report.txt
notes.txt notes.txt

11. Collapse whitespace to a hyphen

Request: Replace each run of whitespace in basenames with one hyphen.

File: collapse-whitespace.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "\\s+",
      "replacewith": "-",
      "casesensitive": false,
      "regularexpressions": true,
      "occurrence": 0
    }
  ]
}
Original filename New filename
annual report.txt annual-report.txt
one three.jpg one-three.jpg

12. Replace only the second occurrence

Request: Change only the second underscore in each basename to a hyphen.

File: replace-second-occurrence.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "_",
      "replacewith": "-",
      "casesensitive": false,
      "regularexpressions": false,
      "occurrence": 2
    }
  ]
}
Original filename New filename
one_two_three_four.txt one_two-three_four.txt

13. Remove a fixed number of leading characters

Request: Remove the first four characters of each basename.

File: remove-prefix-characters.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "remove",
      "active": true,
      "applyto": "name",
      "removetype": "position",
      "start": "1",
      "count": "4",
      "backwards": false,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
old_report.pdf report.pdf
old_photo.jpg photo.jpg

14. Remove characters from the end

Request: Remove the last four characters of each basename.

File: remove-suffix-characters.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "remove",
      "active": true,
      "applyto": "name",
      "removetype": "position",
      "start": "1",
      "count": "4",
      "backwards": true,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
report_old.pdf report.pdf
photo_old.jpg photo.jpg

15. Remove bracketed text

Request: Remove a space followed by a bracketed suffix from the basename.

File: remove-bracketed-text.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "remove",
      "active": true,
      "applyto": "name",
      "removetype": "pattern",
      "pattern": " \\[[^\\]]*\\]$",
      "regularexpressions": true,
      "casesensitive": false,
      "location": "anywhere"
    }
  ]
}
Original filename New filename
report [draft].pdf report.pdf
photo [copy].jpg photo.jpg

16. Use the separate Remove Pattern method

Request: Using the separate Remove Pattern method, remove a leading TEMP_ prefix.

This example uses removepattern. For new pattern-removal tasks, prefer remove with removetype: "pattern".

File: legacy-remove-pattern.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "removepattern",
      "active": true,
      "applyto": "name",
      "pattern": "^TEMP_",
      "regularexpressions": true,
      "casesensitive": false
    }
  ]
}
Original filename New filename
TEMP_report.txt report.txt
keep.txt keep.txt

17. Trim edge punctuation

Request: Trim spaces, underscores and hyphens from both ends of the basename.

File: trim-edges.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "trim",
      "active": true,
      "applyto": "name",
      "characters": " _-",
      "location": "start_and_end",
      "casesensitive": false,
      "inversematch": false
    }
  ]
}
Original filename New filename
__report--.pdf report.pdf
-photo_.jpg photo.jpg

18. Move a segment within the basename

Request: Move the first two characters of each basename to its end.

The destination is beyond these basenames, so the moved segment is appended. This moves characters, not files.

File: move-characters.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "move",
      "active": true,
      "applyto": "name",
      "movefrom": "1",
      "movecount": "2",
      "moveto": "999",
      "relative": false,
      "backwards": false,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
ABreport.txt reportAB.txt
XYphoto.jpg photoXY.jpg

19. Swap artist and title

Request: Swap the parts around the first space-hyphen-space separator.

File: swap-parts.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "swap",
      "active": true,
      "applyto": "name",
      "separator": " - ",
      "occurrence": 1
    }
  ]
}
Original filename New filename
Artist - Title.mp3 Title - Artist.mp3
Band - Song.flac Song - Band.flac

20. Increase an existing number

Request: Add 10 to the first existing number, keeping three-digit padding.

File: increase-existing-number.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "renumber",
      "active": true,
      "applyto": "name",
      "numberposition": 1,
      "change": "relative",
      "newnumber": 1,
      "numberdifference": 10,
      "skip": 1,
      "zeropad": "manual",
      "numberlength": 3,
      "negativenumbers": false
    }
  ]
}
Original filename New filename
image_001.jpg image_011.jpg
image_020.jpg image_030.jpg
cover.jpg cover.jpg

21. Replace an existing number with a new sequence

Request: Renumber the first existing number as 100, 105, 110 in the displayed order.

File: renumber-existing-sequence.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "renumber",
      "active": true,
      "applyto": "name",
      "numberposition": 1,
      "change": "absolute",
      "newnumber": 100,
      "numberdifference": 1,
      "skip": 5,
      "zeropad": "manual",
      "numberlength": 3,
      "negativenumbers": false
    }
  ]
}
Original filename New filename
item_7.txt item_100.txt
item_8.txt item_105.txt
item_9.txt item_110.txt

22. Assign an explicit list of names

Request: Name the first three files Introduction, Methods, Results, preserving extensions.

The input order must match the displayed list. newnames is a single JSON string containing escaped newlines.

File: explicit-list.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "list",
      "active": true,
      "applyto": "name",
      "newnames": "Introduction\nMethods\nResults"
    }
  ]
}
Original filename New filename
a.txt Introduction.txt
b.txt Methods.txt
c.txt Results.txt

23. Apply multiple replacement rows

Request: Change underscores to spaces, then change draft to final.

File: ordered-replacements.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "listreplace",
      "active": true,
      "applyto": "name",
      "replace": [
        "_",
        "draft"
      ],
      "replacewith": [
        " ",
        "final"
      ],
      "casesensitive": false,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
draft_report.txt final report.txt
draft_photo.jpg final photo.jpg

24. Apply a method only to PDFs

Request: Prefix only PDF basenames with Doc_.

File: conditional-prefix.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "add",
      "active": true,
      "applyto": "name",
      "add": "Doc_",
      "position": "1",
      "backwards": false,
      "regularexpressions": false,
      "condition": {
        "active": true,
        "field": "ext",
        "match": "equals",
        "pattern": "pdf",
        "notmatching": false
      }
    }
  ]
}
Original filename New filename
report.PDF Doc_report.PDF
photo.jpg photo.jpg

25. Compose methods in order

Request: Replace underscores with spaces, then prefix the resulting basename with Copy_.

Add operates on the current name, so it preserves the earlier replacement.

File: ordered-cleanup.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "_",
      "replacewith": " ",
      "casesensitive": false,
      "regularexpressions": false,
      "occurrence": 0
    },
    {
      "methodname": "add",
      "active": true,
      "applyto": "name",
      "add": "Copy_",
      "position": "1",
      "backwards": false,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
red_car.JPG Copy_red car.JPG

26. Distinguish original names from current names

Request: Replace underscores with spaces, then rebuild the name as copy_ plus the ORIGINAL basename.

The underscore returns because <Name> reads the original basename. Use Add instead when the intention is to prefix the already-edited name.

File: original-name-tag.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "_",
      "replacewith": " ",
      "casesensitive": false,
      "regularexpressions": false,
      "occurrence": 0
    },
    {
      "methodname": "newname",
      "active": true,
      "applyto": "name",
      "mask": "copy_<Name>"
    }
  ]
}
Original filename New filename
red_car.JPG copy_red_car.JPG

27. Preserve Unicode text

Request: Replace underscores with spaces and prefix the Unicode basename with Arkiv_.

File: unicode-text.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "_",
      "replacewith": " ",
      "casesensitive": false,
      "regularexpressions": false,
      "occurrence": 0
    },
    {
      "methodname": "add",
      "active": true,
      "applyto": "name",
      "add": "Arkiv_",
      "position": "1",
      "backwards": false,
      "regularexpressions": false
    }
  ]
}
Original filename New filename
Müller_Øresund.txt Arkiv_Müller Øresund.txt
東京_写真.jpg Arkiv_東京 写真.jpg

28. Store a simple JavaScript method

Request: Use a Script method to append _done to the current basename.

The script is an Advanced Renamer method body inside a JSON string. No external JavaScript module is imported.

File: script-suffix.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "script",
      "active": true,
      "applyto": "name",
      "script": "return item.newBasename + \"_done\";",
      "prescript": ""
    }
  ]
}
Original filename New filename
report.pdf report_done.pdf

29. Set the modification timestamp

Request: Set the file modification timestamp to 6 November 2026 at 12:30:00 without renaming the file.

Timestamp applyto is modified, not name. This changes filesystem metadata when the batch runs. The expected timestamp is local wall-clock time, subject to filesystem support.

File: set-modified-timestamp.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "timestamp",
      "active": true,
      "applyto": "modified",
      "change": "absolute",
      "year": 2026,
      "month": 11,
      "day": 6,
      "hour": 12,
      "minute": 30,
      "second": 0
    }
  ]
}
Original filename New filename
report.txt report.txt
Filename Modified timestamp before Modified timestamp after
report.txt 2025-01-02T03:04:05 2026-11-06T12:30:00

30. Move files without renaming

Request: Move these files into an Output subfolder of their source folder, preserving the filenames.

The empty methods array preserves filenames. batchmode selects the move operation; outputfolder is relative to each source folder.

File: move-without-renaming.aren

{
  "type": "project",
  "batchmode": "move",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "outputfolder": "Output",
  "methods": []
}
Original filename New filename
report.pdf report.pdf
photo.jpg photo.jpg

31. Copy files without renaming

Request: Copy these files into an Output subfolder of their source folder, preserving the filenames.

The empty methods array preserves filenames. batchmode selects the copy operation; outputfolder is relative to each source folder.

File: copy-without-renaming.aren

{
  "type": "project",
  "batchmode": "copy",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "outputfolder": "Output",
  "methods": []
}
Original filename New filename
report.pdf report.pdf
photo.jpg photo.jpg

32. Clean native metadata with tag modifiers

Request: Use each SVG file's native Title metadata as its basename, trimming whitespace, lowercasing, and replacing spaces with underscores.

scan_1.svg has Title Coastal Sunset ; scan_2.svg has Title Forest Path. These are native metadata values, not the original basenames. The modifiers run left to right and the SVG extension is preserved. See Tag modifiers.

File: metadata-tag-modifiers.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newname",
      "active": true,
      "applyto": "name",
      "mask": "<Title:trim:lower:replace: :_>"
    }
  ]
}
Original filename New filename
scan_1.svg coastal_sunset.svg
scan_2.svg forest_path.svg

33. Fall back between metadata tags and literal text

Request: Name SVG files from Title, otherwise Desc, otherwise the literal Untitled; lowercase the selected value and replace spaces with underscores.

scan_1.svg has Title Coastal Sunset and Desc Evening View; scan_2.svg has only Desc Forest Path; scan_3.svg has neither field. Desc is the native SVG description field. ||Desc tries another tag, while |Untitled supplies literal text. Both fallbacks precede the modifiers, which apply to the selected value. See Tag fallback.

File: metadata-tag-fallback.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "newname",
      "active": true,
      "applyto": "name",
      "mask": "<Title||Desc|Untitled:lower:replace: :_>"
    }
  ]
}
Original filename New filename
scan_1.svg coastal_sunset.svg
scan_2.svg forest_path.svg
scan_3.svg untitled.svg

34. Rearrange captures with backslash substitutions

Request: Move a leading YYYY-MM-DD date after the title using backslash capture substitutions, preserving the extension.

The replacement uses \4, \3, \2, and \1, equivalent to $4, $3, $2, and $1. Every backslash is doubled in JSON. Files without the full pattern remain unchanged. See Regex replacement text.

File: regex-backslash-captures.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "^(\\d{4})-(\\d{2})-(\\d{2})_(.+)$",
      "replacewith": "\\4_\\3-\\2-\\1",
      "casesensitive": false,
      "regularexpressions": true,
      "occurrence": 0
    }
  ]
}
Original filename New filename
2026-11-06_report.txt report_06-11-2026.txt
2025-03-09_photo.jpg photo_09-03-2025.jpg
notes.txt notes.txt

35. Change the case of regex captures

Request: Uppercase the first word and lowercase the second word in two-part names, replacing the underscore with a hyphen.

\U\1 uppercases group 1 and \L$2 lowercases group 2. The dollar and backslash capture forms can be mixed. Bare \U1 or \L2 would insert literal digits. Unicode letter matching includes accented letters. See Capture substitutions.

File: regex-capture-case.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "^(\\p{L}+)_(\\p{L}+)$",
      "replacewith": "\\U\\1-\\L$2",
      "casesensitive": false,
      "regularexpressions": true,
      "occurrence": 0
    }
  ]
}
Original filename New filename
Müller_REPORT.txt MÜLLER-report.txt
François_PHOTO.jpg FRANÇOIS-photo.jpg

36. Rearrange named regex captures

Request: Move the number in a name to the front, using named regex captures.

Named captures use (?<part>...) in the pattern and ${part} in the replacement. These are regex captures, distinct from Advanced Renamer metadata tags. See Regex patterns.

File: regex-named-captures.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "^(?<title>\\p{L}+)_(?<number>\\d+)$",
      "replacewith": "${number}_${title}",
      "casesensitive": false,
      "regularexpressions": true,
      "occurrence": 0
    }
  ]
}
Original filename New filename
report_123.txt 123_report.txt
photo_007.jpg 007_photo.jpg

37. Replace numbers before a suffix with lookahead

Request: Replace digit sequences immediately before _take with PHOTO, leaving the suffix and other numbers intact.

The lookahead (?=_take) tests the suffix without including it in the match. \d+ matches the digits to replace. See Regex strings and escaping.

File: regex-lookahead.aren

{
  "type": "project",
  "batchmode": "rename",
  "pairrename": false,
  "foldermode": false,
  "namecollision.rule": "fail",
  "methods": [
    {
      "methodname": "replace",
      "active": true,
      "applyto": "name",
      "replace": "\\d+(?=_take)",
      "replacewith": "PHOTO",
      "casesensitive": false,
      "regularexpressions": true,
      "occurrence": 0
    }
  ]
}
Original filename New filename
IMG_123_take_2.jpg IMG_PHOTO_take_2.jpg
scan_123.jpg scan_123.jpg