Find numerical pattern replace with Text + numerical pattern

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
steve1040
Posts: 39
Joined: Fri Oct 13, 2006 2:19 am

Find numerical pattern replace with Text + numerical pattern

Post by steve1040 »

I have several hundred files with data looking like this

1.jpg
2.jpg
3.jpg
4.jpg
13.jpg

I need to replace with

nnu1.jpg
nnu2.jpg
nnu3.jpg
nnu4.jpg
nnu13.jpg

Also is there a way I can pass Textpad the name of the folder the file is in?

So using the same example

1.jpg
2.jpg
3.jpg
4.jpg
13.jpg

would become

Foldername1.jpg
Foldername2.jpg
Foldername3.jpg
Foldername4.jpg
Foldername13.jpg


Thanks
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

If you want to replace every instance of n.jpg, where n is any number with any number of digits and where n.jpg is the entire file name, try this:
Find what: \<[0-9]+\.jpg
Replace with: nnu\0

[X] Regular expression
If you want to replace every instance of n.jpg at the beginning of a line, where n is anything at all, try this:
Find what: ^.*.jpg
Replace with: nnu\0

[X] Regular expression
You can copy the full path and name of the current file to the clipboard with Edit | Copy Other | File Name. To get the path part you'll have to remove the final file name component.
Post Reply