Copy link to clipboard
Copied
I have a series of files that are like: 230167 firstname lastname.jpg
I would like to remove everything but the first 6 digits of the file name so that I'm left with 230167.jpg
Thanks
Enid
2 Correct answers
@Enid26229849jlhv – try the following:
Find using Regular Expression capture groups – starting with only 6 digits from the left + extension:
(^\d{6})(.+)(\.[^\.]+$)
Replace (using back-references to the capture groups):
$1$3
or
Find using Regular Expression capture groups – first 6 digits or characters from the left + extension:
(^.{6})(.+)(\.[^\.]+$)
Replace (using back-references to the capture groups):
$1$3
or
Find using Regular Expression capture groups – first word from the left +
...A copy/paste from my reply to your PM...
You can add a prefix the "default" way:
Or the alternative is what Adobe call "String Substitution" (find/replace with a regular expression option):
Find (start/far left of the text string):
^
Replace (P + space):
P
Copy link to clipboard
Copied
@Enid26229849jlhv – try the following:
Find using Regular Expression capture groups – starting with only 6 digits from the left + extension:
(^\d{6})(.+)(\.[^\.]+$)
Replace (using back-references to the capture groups):
$1$3
or
Find using Regular Expression capture groups – first 6 digits or characters from the left + extension:
(^.{6})(.+)(\.[^\.]+$)
Replace (using back-references to the capture groups):
$1$3
or
Find using Regular Expression capture groups – first word from the left + extension:
(^.+?\b)(.+)(\.[^\.]+$)
Replace (using back-references to the capture groups):
$1$3
Copy link to clipboard
Copied
Thanks, that worked!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Excellent Stephen, works perfectly. Many thanks. Would you mind explaining the operators you used and what they are doing?
Copy link to clipboard
Copied
Excellent Stephen, works perfectly. Many thanks. Would you mind explaining the operators you used and what they are doing?
By NMT
I posted a couple of times... Are you referring to the post marked as a correct answer?
Copy link to clipboard
Copied
Another question! I would like to add P to a file name. Example:
P 230167.jpg
Thanks for
Copy link to clipboard
Copied
A copy/paste from my reply to your PM...
You can add a prefix the "default" way:
Or the alternative is what Adobe call "String Substitution" (find/replace with a regular expression option):
Find (start/far left of the text string):
^
Replace (P + space):
P
Copy link to clipboard
Copied
Thanks so much!

