Robert002
Robert002

Reputation: 73

How to find and replace names witn numbering at the end in Notepad++?

I want to replace all similar names in text with Notepad++

image_1.jpg
image_2.jpg
image_3.jpg
...
image_n.jpg

to only one name: "image_x.jpg".

What is the simplest way to automate this task?

Upvotes: 1

Views: 70

Answers (2)

Kent
Kent

Reputation: 195079

Search :

^image_\d+\.jpg$

Replace with:

image_x.jpg

if the text is exactly same as it is in question, you could use:

search _[^.]* replace it with _x

EDIT

as OP commented image2.jpg is also a possibility., the substitution can be done in:

search:

(image)_?(\d+)

replace with

\1_\2

this will change:

image3.jpg
image_1.jpg

into:

image_1.jpg
image_3.jpg

if you want to have a fixed name:

replace with:

\1_x

Note, if notepad++ use $ to reference group match, use $1_$2

Upvotes: 5

polkduran
polkduran

Reputation: 2551

Regex : image_\d+\.jpg

Replacement : image_x.jpgenter image description here

Upvotes: 3

Related Questions