#1 2010-01-29 05:49

LostHere
Member
Registered: 2006-06-19
Posts: 6

Remove meta tag from file name

Hi,

I know that Renamer has the option of inserting a meta tag into the filename.  However, what do I need to do to remove a meta tag from a name?  For example, I have a HTPC setup with folders/files structured as follow:

Series-name1\Series-name1 01 - titleA.avi
Series-name1\Series-name1 02 - titleB.avi
Series-name1\Series-name1 Special.avi
Series-name2\Series-name2 01 - titleC.avi
Series-name2\Series-name2 02 - titleD.avi
Series-name2\Series-name2 Special.avi

I was trying to rename them to:

Series-name1\e01 - titleA.avi
Series-name1\e02 - titleB.avi
Series-name1\Special.avi
Series-name2\e01 - titleC.avi
Series-name2\e02 - titleD.avi
Series-name2\Special.avi

I know the folder name meta tag is :File_FolderName: but it seems I can only use it for inserting and not removing?  Or is there a way to do this already?

Thanks.

Last edited by LostHere (2010-01-29 05:50)

Offline

#2 2010-01-29 10:12

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Remove meta tag from file name

Hi LostHere, here you are not lost anyway.

Laying beside your  "meta tag" approach, it seams you just want to remove all signs before the first space?

FROM:
Series-name1 02 - titleB.avi
Series-name1 Special.avi
TO:
02 - titleB.avi
Special.avi

So *I* would use RegEx for that.
Split your example into parts and then reorder the output, or rather drop parts as in your issue:
1) Find all non-greedy till an space => .+?
2) Find all of the rest => .+ and group them to use this later as the new name => (.+)

So add an Rule RegEx:
Expression: .+? (.+)
Replace: $1


I don't understand where this "e" in "e02 - titleB.avi" comes from...
but if you need it you can just use (i have no time to think about an better approach right now)
Expression: .+? (.+)
Replace: e$1

And then use an second rule REPLACE
Find: eSpecial
Repl: Special
to remove this leading "e" from "Special" again. Quick and dirty.

HTH?

See the WIKI
=> http://www.den4b.com/wiki/ReNamer:Rules for more about using Rules and
=> http://www.den4b.com/wiki/ReNamer:Regular_Expressions for more about the RegEx Syntax.


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2010-01-29 10:21

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Remove meta tag from file name

@Denis

i just made an test:

- i use INSERT rules "Add meta tag" feature to get the meta tag ":File_FolderName:"
- then i pasted this meta tag into the REMOVE and the REPLACE -find field, but
there the meta tag was not recognized as such.

...maybe an improvement idea?

I bet i know your answer.... use PascalScript  tongue


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#4 2010-01-30 00:28

LostHere
Member
Registered: 2006-06-19
Posts: 6

Re: Remove meta tag from file name

Thanks for the help.  Unfortunately, the series names are not as simple as just a bunch of Series-name#.  Some of them have spaces, some have periods, some have a whole bunch of numbers, etc.  The only easy way to get rip of them is by matching with the folder names.

PascalScript would probably be able to do this.  I am not too familiar with this language however (maybe it's time to learn it).  It also looks like I can't use meta tag in the regular expression neither.

Offline

#5 2010-01-30 01:18

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Remove meta tag from file name

LostHere wrote:

Thanks for the help.  Unfortunately, the series names are not as simple [...]
The only easy way to get rip of them is by matching with the folder names.

That's why it's always an very good idea to provide REAL examples of the file names in question.
And in all possible manner of them too. Only that way we can provide an good support
without doing it again and again by only guessing what the quester may try to accomplish.

As already mentioned, we can use PascalScript to get the parent folder
and use this result as match for an search&replace like:



var
 Folders: TStringsArray;
 UBound: Integer;
 Parent, Parent_WholeWordOnly: WideString;
 
begin

 Folders := WideSplitString(WideExtractFileDir(FilePath), '\');
 UBound := Length(Folders) - 1;
 Parent := Folders[UBound];
 Parent_WholeWordOnly := '\b'+Parent+'\b';

 
           //ReplaceRegEx(haystack,match,replace,case sensitive, use substitution )
           //Find <parent> and replace with nothing <' '>
           //Maybe you may want to fine-tune the RegEx. See the wiki for an RegEx guide.

 FileName := ReplaceRegEx(FileName, Parent,'', False, False);


end.


or, as i see now, for this simple task we can do this PS more simple:

var
   Parent: WideString;
 
begin 
   Parent   := ReplaceRegEx(FilePath, '.+\\(.+)\\.+', '$1', False, True);
   FileName := ReplaceRegEx(FileName, '\b'+Parent+'\b', '', False, False);
end.

HTH?

See the WIKI for more about using Rules
=> http://www.den4b.com/wiki/ReNamer:Rules
in special
=> http://www.den4b.com/wiki/ReNamer:Rules:PascalScript
and for more about the RegEx Syntax
=> http://www.den4b.com/wiki/ReNamer:Regular_Expressions

Last edited by Stefan (2010-01-30 01:43)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#6 2010-01-30 02:08

LostHere
Member
Registered: 2006-06-19
Posts: 6

Re: Remove meta tag from file name

Thank you very much!  The PascalScript works smile

Offline

Board footer

Powered by FluxBB