Removing text from filename

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Removing text from filename Thu Mar 05, 2020 10:19 am • by mikejandreau
I'm pretty sure I need to rename my file, but can't figure out the right syntax.

After I run a file through Handbrake, I'm appending _hb to the filename (since Handbrake can't overwrite its source file to give me the same name).

So I end up with Movie Name_hb.mp4 as my completed file.

I want to remove just the _hb from the filename as part of one of my Rules.

Can someone help point me in the right direction?
mikejandreau
 
Posts: 36
Joined: Sun Sep 09, 2018 8:28 am

Re: Removing text from filename Thu Mar 05, 2020 11:06 am • by Mr_Noodle
Look up "match patterns" in the help. You can create a custom attribute to match everything up to the _hb. You can then use that in the Rename action by itself to get the result you want.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Removing text from filename Thu Mar 05, 2020 11:21 am • by mikejandreau
I think I've got it right. Can you verify what I've done is correct?

Here's my Rule: https://take.ms/V4x3B
Here's my custom pattern: https://take.ms/dCYY7S
I'm inferring this as: TheNameOfTheMovie (Year)_hb

Is that right?
... == (TheNAmeOfTheMovie)
a1% == (
123 == Year
a1% == )
% == _
a == h
b == b

That matches my pattern for movies.

Then my Rename rule is: https://take.ms/fZNZz

I'm using "Replace Text" to replace the "_hb" with "", but it looks like it replaces everything after that, too. So I added .mp4 to the Rename Action.

I tried added it in the "Replace text" (ie; "_hb.mp4" with ".mp4", but that didn't work right).

I think what I've done here is correct (it's working in my tests), but wanted to confirm this is what you were suggesting in the docs.
mikejandreau
 
Posts: 36
Joined: Sun Sep 09, 2018 8:28 am

Re: Removing text from filename Fri Mar 06, 2020 11:07 am • by Mr_Noodle
You could do it with Replace text though it will not work as expected if _hb appears anywhere else in the name. Also, you may be overthinking it.

Have your custom attribute just match (...). You then have a pattern like (•Movie Name)_hb. That will grab all the text up to _hb. When you use (•Movie Name) in your Rename action, it will have just the part you want.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Removing text from filename Tue Mar 31, 2020 11:50 am • by Yak_Forger
I can confirm that this works fine, has it been appropriate for you as well, Mike?
Yak_Forger
 
Posts: 5
Joined: Thu Mar 26, 2020 5:39 am


Return to Support