Need help creating renaming expression

A swapping-ground for Regular Expression syntax

Need help creating renaming expression

Postby marvinsd2 » Tue May 28, 2013 3:42 am

Hello all,

I've got a few thousand video clips that I would like rename. There are two things I'm trying to do.

First, most, but not all, file names begin with the name of the site. Examples are "bing.com." and "youtube.com.". Yes, there is a period following the word "com". So for those file names that start with "xxx.com.", can someone tell me how to strip it out?

Second, most, but not all, file names end with some kind of site ID or advert of some kind. When this is present, it is always preceded with either a double space or a hyphen. So what I want to do is drop the double space or hyphen (if present) and any text that follows. Can anyone tell me how this is done?

I've tried creating expressions to do these things, but they all have had undesired results.

Thank you for any help.
Marvin
marvinsd2
 
Posts: 1
Joined: Tue May 28, 2013 3:32 am

Re: Need help creating renaming expression

Postby Stefan » Tue May 28, 2013 10:03 am

marvinsd2 wrote:Hello all,

I've got a few thousand video clips that I would like rename. There are two things I'm trying to do.

First, most, but not all, file names begin with the name of the site. Examples are "bing.com." and "youtube.com.". Yes, there is a period following the word "com". So for those file names that start with "xxx.com.", can someone tell me how to strip it out?

Second, most, but not all, file names end with some kind of site ID or advert of some kind. When this is present, it is always preceded with either a double space or a hyphen. So what I want to do is drop the double space or hyphen (if present) and any text that follows. Can anyone tell me how this is done?

I've tried creating expressions to do these things, but they all have had undesired results.

Thank you for any help.
Marvin


Quick and dirty answer (no time)


To match a literal dot you have to escape them: \.
Match: ^.+?\..+?\.(.+)$
Repla: \1


To match two spaces OR an hyphen
Match: ^(.+)(##|-).+$
Repla: \1

instead of '##' insert two spaces ' '

Test always with copies of your real files and be sure to have a backup.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions