Welcome, Guest
Python Scripts for ComicRack

TOPIC: Import tags from filename with regular expressions

Re: Import tags from filename with regular expressions 5 years 7 months ago #22109

  • perezmu
  • perezmu's Avatar
  • Offline
  • Platinum Boarder
  • Posts: 1114
  • Thank you received: 64
  • Karma: 51
Thanks for this!
The administrator has disabled public write access.

Re: Import tags from filename with regular expressions 5 years 4 months ago #24450

  • Dorin
  • Dorin's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 12
  • Karma: 0
Can someone help me with this? I am new to regex. I have the following regex now:
.*-(?<Month>\d{2})-.*(?<Year>\d{4})

This correctly fills out the month and year for me. What I need now is to combine the month and year to make a "Number". For example:

"Heavy Metal -01-Vol-07\10 V1977 1984" => Month=01, Year=1984, Number=198401

How can I create a group "Number" that gets it's values from the groups Month and Year?
The administrator has disabled public write access.

Re: Import tags from filename with regular expressions 5 years 2 months ago #25535

  • jeroenwalter
  • jeroenwalter's Avatar
  • Offline
  • Gold Boarder
  • Posts: 233
  • Thank you received: 38
  • Karma: 15
You guys just saved me lots of work with this plugin, so a very big thanks to all of you !
The administrator has disabled public write access.

Case Sensitivity 5 years 4 weeks ago #26663

  • jorgev
  • jorgev's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 12
  • Karma: 0
Hello,

I could use a littel help with my regex

In my library some series appear double.

For instance the following series:

"De bal"=> 2 books
"De Bal"=> 1 book

Okey so the only difference is a capital.

I already renamed the files on my hard drive, so all words begin with a capital.
then i tried to run the folowing regex

(?:@S@ )(?<Series>.*)(?: @RN@ )(?:0{0,3})(?<Number>.*)(?: @T@ )(?<Title>.*)

The problem is my regex does nothing if the only dofference is a capital.

i tried to force case sensitivity with the -i switch

(?:@S@ )(?-i<Series>.*)(?: @RN@ )(?:0{0,3})(?<Number>.*)(?: @T@ )(?-i<Title>.*)

But this one throws an error

Anyone knows how i can build in case sensitivity?
Normally it should be case sensitive by default but it clearly isn't.
The administrator has disabled public write access.

Re: Case Sensitivity 5 years 4 weeks ago #26666

  • Stonepaw
  • Stonepaw's Avatar
  • Offline
  • Moderator
  • Posts: 921
  • Thank you received: 268
  • Karma: 173
Can you post the full file path of something you want to capture. This regex makes no sense to me without the context.

Also the i switch turns case insensitivity ON.
The administrator has disabled public write access.

Re: Case Sensitivity 5 years 4 weeks ago #26667

  • jorgev
  • jorgev's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 12
  • Karma: 0
2 example files: 2 books, same series, once with and once without capital (Druïden)

"G:\D\Druïden, De\@S@ De Druïden @RN@ 01 @T@ Het Mysterie Van De Ogams.cbr"
"G:\D\Druïden, De\@S@ De druïden @RN@ 03 @T@ De Lans Van Lugh.cbr"


I'll try to explain it better:

(?:@S@ )(?<Series>.*)(?: @RN@ )(?:0{0,3})(?<Number>.*)(?: @T@ )(?<Title>.*)
This regex wil capture the series name "De Druïden", the reading number, and the title of the book.
the regex works just fine.

Now my problem:
If i order my books by series, then 2 series will appear( De Druïden & De druïden )
I've got a lot of series in my library with the same problem.

So i ran a regex file renamer tool on my books on my NAS and did a "capitalize each first letter of each word"

After that i wanted to capture these modifications in my library with my regex.
Now here's the problem. My library does not change, so i keep having double series.

i already solved this now,i just deleted all books from my library and rescanned all my books, and then ran my regex again.

Now all my series are ok.
But this is no elegant solution.

Now i just did a test:
It looks like Comicrack does not capture the "case change" on the filename.
Just try it for yourself, change the case in the filename of any series on your HD, and then do "Scan book folders"

You'll see that Comicrack does not capture that.

Ofcours if you dont change the case but change lettre, then comicrack will capture that after "scan book folders"

Not sure if that's a bug or a feature :)

For me it's anoying, i have to make sure i capitalize each first lettre of each word in my filenames before i copy the files to my books folders.

And indeed the i parameter activates case insensitivity, but the -i parameter should force case sensitive :)

But i understand now the regex is not the problem
Last Edit: 5 years 4 weeks ago by jorgev. Reason: extra info
The administrator has disabled public write access.

Re: Case Sensitivity 5 years 4 weeks ago #26668

  • Stonepaw
  • Stonepaw's Avatar
  • Offline
  • Moderator
  • Posts: 921
  • Thank you received: 268
  • Karma: 173
Well at least you got it done in the end :)

You could probably make a very simple script for CR that capitalizes every word in the series field. That would probably be the easiest solution.
The administrator has disabled public write access.

Re: Import tags from filename with regular expressions 4 years 1 month ago #36853

Hi,

I've just started a week ago to use CR and I'm loving it. I've even learned how to use REGEX for this marvelous script. I'm using this page to check my REGEX expresions:

www.debuggex.com/

So now I don't need to download expresso. Anyway, sometimes I get this erro: "exception has been thrown by the target of an invocation."

I don't know what the #$%#^ could it be. But it's pretty annoying because i cannot use the script. I've a file structure like this:

C:\Users\Carlos\Books and Articles\Comics\Fantomas\0-004 - El Emperador de las Tinieblas

Where the only two things I want to extract are "004" for the Number and "El Emperador de las Tinieblas" for the title. I used this regex:

^..\\(.{5})\\(.{6})\\(.{18})\\(.{6})\\(.{8})\\([0-9])-(?<Number>[0-9]){3} - (?<Title>.{2,})

But nothing, please help me.

Carlos
The administrator has disabled public write access.

Import tags from filename with regular expressions 3 years 7 months ago #39006

  • mrx65a
  • mrx65a's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
Hi everybody, can someone help me how to convert a filename like <seriesgroup> - <volume> - <series> - <number> - <title> with regex to the right tags?
I can't seem to get it done. What I have is:

(?<Seriesgroup>.*) - (?<Volume>\d+?) - (?<Series>[^\\]*?) - (?<Number>.+?) - (?<Title>.*)

Doesn't work...

Please help!

Regards,
Mark
The administrator has disabled public write access.

Update, tweaks and fixes 2 years 4 weeks ago #43801

  • freMea
  • freMea's Avatar
  • Offline
  • Junior Boarder
  • Posts: 38
  • Thank you received: 5
  • Karma: 1
Hi,

I modded and improved this script. Please find the new version in this topic.

Enjoy
The administrator has disabled public write access.
Time to create page: 0.224 seconds

Who's Online

We have 248 guests and 2 members online