Regex to strip the first words from filename

Post variable and regex related tips, questions.

Regex to strip the first words from filename

Postby melvin » Tue Nov 25, 2014 5:51 pm

User support request:

I need help to rename file during transfer. There’s a title to each filename, and then a code. For Example, the filename in the upper-left is…
MY TEST CLIENT W1RD-0008000.mp3

The goal, to strip MY TEST CLIENT , and leave just the W1RD-008000.mp3.

Same with the rest of the files, we only need the last code, which is always the last unbroken chain of letters and numbers.

Thanks!
melvin
Site Admin
 
Posts: 979
Joined: Thu May 25, 2006 10:20 am
Location: Santa Barbara, california

Re: Regex to strip the first words from filename

Postby melvin » Tue Nov 25, 2014 5:52 pm

Try:
Rename field = ([a-zA-Z0-9]{1,}-[0-9]{1,}.mp3)<GROUP>group1

a-z matches lower case
A-Z matches upper case
0-9 matches any number
[a-zA-Z0-9] is a single character
[0-9] is a single number
{1,} specifies one or more of the previous character
( ) groups the regex
group1 returns the first group, in this case the group1 contains the characters after the last space and includes .mp3.
melvin
Site Admin
 
Posts: 979
Joined: Thu May 25, 2006 10:20 am
Location: Santa Barbara, california


Return to Variables and Regular Expressions

Who is online

Users browsing this forum: No registered users and 1 guest

cron