Welcome, Guest
Python Scripts for ComicRack

TOPIC: Import tags from filename with regular expressions

Re:Import tags from filename with regular expressi 8 years 1 month ago #4572

  • vixenfinder
  • vixenfinder's Avatar
  • Offline
  • Junior Boarder
  • Posts: 35
  • Karma: 2
I apply the script to either one or a selection of them and then after I click Apply it pops up as an error messages. If I'm working on a whole selection then I have to redo it for each comic.
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 8 years 1 month ago #4573

  • Yellowbox
  • Yellowbox's Avatar
  • Offline
  • Junior Boarder
  • Posts: 25
  • Thank you received: 10
  • Karma: 3
Have you tried restarting CR?
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 7 years 10 months ago #5133

  • bibu
  • bibu's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 9
  • Karma: 0
Hi guys,

I have exactly the same issue.
I am running Win7 or vista (tried on both) and I try to launch the program under WinXP comptaibility option and/or administrator right but always the same issue.
I addeed -ssc to get logs and here are the results:
Calling 'StartTagsFromName'...
Compilation of 'TagsFromName.py'
.+\\(?<Series>.*)\\(?<Title>.*)
.+\\(?<Series>.*)\\(?<Title>.*)
File C:\Users\bibu\Pictures\BD\gamemaster\gamemaster - 1a4
Series gamemaster
Title gamemaster - 1a4
Local variable 'matchTags' referenced before assignment.

regards
Bibu
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 7 years 10 months ago #5134

  • bibu
  • bibu's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 9
  • Karma: 0
ok I found the bugs, the matchtags variable was missing in the script...

CU
Bib
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 7 years 2 months ago #10365

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 233
Trying to rename 2000AD comics with this script..

Somehow, ComicRack errs in correctly guessing the default fields in case of 2000AD comics.

So, 2000AD 1704 is read as:


I tried this script, but I do not know one bit about Regex (I tried, but i find it very difficult). I used this code:
(?<Series>[^\\]*?)(?<Number>.+?)

and I got this result:



that clearly shows that my code is wrong.

So, guys here who know about Regex can please help me out.. :unsure:
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 7 years 2 months ago #10366

  • Stonepaw
  • Stonepaw's Avatar
  • Offline
  • Moderator
  • Posts: 921
  • Thank you received: 268
  • Karma: 173
Try this:
\\(?<Series>2000AD).*?(?<Number>\d+)

Expresso is a tool that can help you create and test regular expressions.
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 7 years 2 months ago #10379

  • 600WPMPO
  • 600WPMPO's Avatar
  • Offline
  • Moderator
  • Posts: 3788
  • Thank you received: 557
  • Karma: 233
Stonepaw wrote:
Try this:
\\(?<Series>2000AD).*?(?<Number>\d+)
Thanks Stoney.. that worked perfectly !

I downloaded Expresso, but may be I needed to devote more time to understand it.. :unsure:
Now Playing: The ComicRack Manual (Online)

See my new comics & gadgets on: Tumblr!
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 7 years 1 month ago #10698

  • freMea
  • freMea's Avatar
  • Offline
  • Junior Boarder
  • Posts: 38
  • Thank you received: 5
  • Karma: 1
I have some issues.

I made a regex using expresso 3.0.3634 that parses those filenames:
S:\Manga - BD\Asterix\Asterix HS Asterix et les indiens
S:\Manga - BD\Asterix\Asterix.HS.La Naissance d'Asterix et Obelix
S:\Manga - BD\Asterix\Asterix, HS, Les 12 travaux d'Astérix

S:\Manga - BD\Asterix\Asterix - Tome 01 - Asterix le Gaulois
S:\Manga - BD\Asterix\Asterix - Tome 02 - La Serpe D'or
S:\Manga - BD\Asterix\Asterix . Tome 3 . Astérix et les Goths
S:\Manga - BD\Asterix\Asterix,T4.Gladiateur
S:\Manga - BD\Asterix\Asterix, T.05, Le Tour de Gaule
S:\Manga - BD\Asterix\Asterix T06 Asterix et Cleopatre

S:\Manga - BD\Asterix\Asterix - Volume 01 - Asterix le Gaulois
S:\Manga - BD\Asterix\Asterix - Volume 02 - La Serpe D'or
S:\Manga - BD\Asterix\Asterix . Vol.3 . Astérix et les Goths
S:\Manga - BD\Asterix\Asterix,V4.Gladiateur
S:\Manga - BD\Asterix\Asterix, V.05, Le Tour de Gaule
S:\Manga - BD\Asterix\Asterix Vol06 Asterix et Cleopatre
to retrieve Serie,Volume,Number|[HS],Title from them.

Here are the good results in expresso

File Attachment:

File Name: ExpressoResults.zip
File Size:1 KB



The regex that does the job is
.*\\(?<Series>[^\\]*?)(?:[\-\.,\s]+v[a-zA-Z\.\s]{0,6}(?<Volume>\d+)|[\-\.,\s]+t[a-zA-Z\.\s]{0,4}(?<Volume>\d+)|[\-\.,\s]+(?<Number>HS))(?:[\-\.,\s]+)(?<Title>.*)

Pretty advanced one!

But when I run it into CR, it simply fails


The log reports:
Calling 'StartTagsFromName'...

.*\\(?<Series>[^\\]*?)(?:[\-\.,\s]+v[a-zA-Z\.\s]{0,6}(?<Volume>\d+)|[\-\.,\s]+t[a-zA-Z\.\s]{0,4}(?<Volume>\d+)|[\-\.,\s]+(?<Number>HS))(?:[\-\.,\s]+)(?<Title>.*)

.*\\(?<Series>[^\\]*?)(?:[\-\.,\s]+v[a-zA-Z\.\s]{0,6}(?<Volume>\d+)|[\-\.,\s]+t[a-zA-Z\.\s]{0,4}(?<Volume>\d+)|[\-\.,\s]+(?<Number>HS))(?:[\-\.,\s]+)(?<Title>.*)

File S:\Manga - BD\Asterix\Asterix - Tome 01 - Asterix le Gaulois

I have selected one file and put only one regex hence I don't know if it's normal that it appears twice in log for one file. Am I clear?

Here are the options checked in expresso to do the job with no errors:


I'd like to use my regex above because it can parse various filenames pattern. It's more simple to use one or two regex pattern than too many for each particular situation. Am I right?

And can TagsFromName auto recall the last regex used in the text field?
Last Edit: 7 years 1 month ago by freMea.
The administrator has disabled public write access.

Re:Import tags from filename with regular expressi 7 years 1 month ago #10700

  • Yellowbox
  • Yellowbox's Avatar
  • Offline
  • Junior Boarder
  • Posts: 25
  • Thank you received: 10
  • Karma: 3
freMea wrote:
I have some issues.
Hey pal, we all got issues. See a doctor.
Moving on...
freMea wrote:
The regex that does the job is
.*\\(?<Series>[^\\]*?)(?:[\-\.,\s]+v[a-zA-Z\.\s]{0,6}(?<Volume>\d+)|[\-\.,\s]+t[a-zA-Z\.\s]{0,4}(?<Volume>\d+)|[\-\.,\s]+(?<Number>HS))(?:[\-\.,\s]+)(?<Title>.*)

Pretty advanced one!

But when I run it into CR, it simply fails
A little too advanced, I think. The simpler the regex, the better the results. But in this case, I think the problem is your multiple <Volume> capture groups. You should collapse your OR ("|") groupings.

I took a few minutes in Expresso and cooked up this one for you:
\\(?<Series>[^\\]*?)\W+?([vt].*?(?<Volume>\d+?)|(?<Number>HS))\W+?(?<Title>\w.+)

Hope this helps!
freMea wrote:
And can TagsFromName auto recall the last regex used in the text field?
Nope, sorry. Cut and paste, brother. Much luck!
Last Edit: 7 years 1 month ago by Yellowbox.
The administrator has disabled public write access.
The following user(s) said Thank You: freMea

Re:Import tags from filename with regular expressi 7 years 1 month ago #10702

  • freMea
  • freMea's Avatar
  • Offline
  • Junior Boarder
  • Posts: 38
  • Thank you received: 5
  • Karma: 1
Thanks for helping.

Your regex is very better than mine ;)

However it still fails to work within CR


One can download an eComic that was a part of my test here

It seems that TagsFromName works great for simple regex as:
\\(?<Series>[^\\]*?) - Tome (?<Volume>\d+) - (?<Title>.*)

but gets buggy with some more complex one as:
\\(?<Series>[^\\]*?)\W+?([vt].*?(?<Volume>\d+?)|(?<Number>HS))\W+?(?<Title>\w.+)

I wish I have the skills to improve the script myself.
The administrator has disabled public write access.
Time to create page: 0.397 seconds

Who's Online

We have 266 guests and 4 members online