#1 2013-08-06 11:57

erebus
Member
Registered: 2013-05-05
Posts: 36

Create Folder & Subfolder according filename

hello
Some time ago on this forum I found a script that I modified for this:

var
  Parts: TStringsArray;
  
begin
  Parts := SubMatchesRegEx(FileName, '(.+) (S\d\d)(.+)', FALSE);
  If (Length(Parts) > 0) then 
    begin
      FileName := Parts[0]+' '+Parts[1]+'\'+Parts[0]+' '+Parts[1]+Parts[2]
      Exit
    end;
  
  Parts := SubMatchesRegEx(FileName, '(.+) (E\d\d.+)', FALSE);
  If (Length(Parts) > 0) then 
    begin
      FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1]
    end;
end.

but now it does enough for me.

I have this:
Babylon 5 S01E02.avi
Star Trek S03E01.avi

With the script i have This:
Babylon 5 S01\Babylon 5 S01E02.avi
S03 Star Trek \ Star Trek S03E01.avi


what I want:
Babylon 5\Babylon 5 S01\Babylon 5 S01E02.avi
Star Trek \ Star Trek S03 \ Star Trek S03E01.avi

Sorry for my english i use google for translate

Thank you very much in advance

Best regards

Offline

#2 2013-08-06 12:42

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Create Folder & Subfolder according filename

For not making a lot of changes what you could do is change this line

FileName := Parts[0]+' '+Parts[1]+'\'+Parts[0]+' '+Parts[1]+Parts[2]

to

FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1]+'\'+Parts[0]+' '+Parts[1]+Parts[2];

If this software has helped you, consider getting your pro version. :)

Offline

#3 2013-08-06 13:00

erebus
Member
Registered: 2013-05-05
Posts: 36

Re: Create Folder & Subfolder according filename

Great
Thanks a lot
I'll make a tutorial
thank you again

Best regards

Offline

#4 2018-11-15 05:47

erebus
Member
Registered: 2013-05-05
Posts: 36

Re: Create Folder & Subfolder according filename

Hello,
my needs for this script have changed.

{ Create Folder & SubFolder }
var
  Parts: TStringsArray;

begin
  Parts := SubMatchesRegEx(FileName, '(.+) (S\d)(.+)', FALSE);
  If (Length(Parts) > 0) then
    begin
      FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1]+'\'+Parts[0]+' '+Parts[1]+Parts[2];
      Exit
    end;

  Parts := SubMatchesRegEx(FileName, '(.+) (E\d\d.+)', FALSE);
  If (Length(Parts) > 0) then
    begin
      FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1]
    end;
end.

I have to modify this script as I could to have this result.

My file in start:
Boku No Hero Academia S3 01.mkv
Darling In The Franxx 01.mkv

With this scrip:
Boku No Hero Academia S3/Boku No Hero Academia S3 01.mkv
Darling In The Franxx/Darling In The Franxx 01.mkv

What i want:
Boku No Hero Academia/Boku No Hero Academia S3/Boku No Hero Academia S3 01.mkv
Darling In The Franxx/Darling In The Franxx 01.mkv

Is it possible?

Thanks for advance.

Best regards

Vincent

Last edited by erebus (2018-11-16 10:25)

Offline

#5 2018-11-17 07:26

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Create Folder & Subfolder according filename

In your post, your script and examples of input/output do not match. Perhaps you have posted a wrong script?

Anyway, below is a script which will convert from:

Boku No Hero Academia S3 01.mkv
Darling In The Franxx 01.mkv

Into:

Boku No Hero Academia\Boku No Hero Academia S3\Boku No Hero Academia S3 01.mkv
Darling In The Franxx\Darling In The Franxx 01.mkv

Script:

var
  Parts: TWideStringArray;

begin
  Parts := SubMatchesRegEx(FileName, '(.+)\s+(S\d+)(\s+\d+\..+)', FALSE);
  if Length(Parts) > 0 then
  begin
    FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1]+'\'+Parts[0]+' '+Parts[1]+Parts[2];
    Exit;
  end;

  Parts := SubMatchesRegEx(FileName, '(.+)\s+(\d+\..+)', FALSE);
  if Length(Parts) > 0 then
  begin
    FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1];
    Exit;
  end;
end.

Offline

#6 2018-11-17 09:20

erebus
Member
Registered: 2013-05-05
Posts: 36

Re: Create Folder & Subfolder according filename

Hello,
Sorry for the old Script.

Thanks its work fine,

I just have rearrange my rules to make them work with your script.

By examples I had to mount befor your script this rule: "^(.*)(\d+).*$" =>"$1$2" (delete all after number a two figure like 01 or 09 etc..).

i'ts crazy just one simply rules make problem.

But ....

Thank again i'ts work great

PS: No relation with this post but i dont now how post this:
in "Clean rules", why not put a check mark to avoid removing the "." has words such as S.W.A.T (acronym) or words of our choice.
it would avoid creating other rules to correct this (like skip number sequence 1.2.3.4).

Thanks again

Best Regards

Vincent

Offline

#7 2018-11-19 11:30

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Create Folder & Subfolder according filename

erebus wrote:

in "Clean rules", why not put a check mark to avoid removing the "." has words such as S.W.A.T (acronym) or words of our choice.
it would avoid creating other rules to correct this (like skip number sequence 1.2.3.4).

Well, exactly, why not? smile

This is a valid feature suggestion!

It could be phrased as "skip capital letter sequences", following the naming pattern of the existing "skip number sequences" option.

The problem with detecting acronyms and abbreviations is that they don't follow a particular pattern, for example: "Ph.D.", "e.g.", "Prof. A. N. Chomsky". Limiting it to just the capital letters certainly makes it easy to implement, but won't cover many use cases.

Offline

#8 2018-11-21 16:10

erebus
Member
Registered: 2013-05-05
Posts: 36

Re: Create Folder & Subfolder according filename

den4b wrote:

Well, exactly, why not? smile

This is a valid feature suggestion!

It could be phrased as "skip capital letter sequences", following the naming pattern of the existing "skip number sequences" option.

Cool , yes

den4b wrote:

The problem with detecting acronyms and abbreviations is that they don't follow a particular pattern, for example: "Ph.D.", "e.g.", "Prof. A. N. Chomsky". Limiting it to just the capital letters certainly makes it easy to implement, but won't cover many use cases.

yes it's not easy.
I'cant help, sorry.

thank you very much

best regars and good luck, I trust in you, your software is top and constantly evolving

Offline

#9 2019-11-09 06:23

erebus
Member
Registered: 2013-05-05
Posts: 36

Re: Create Folder & Subfolder according filename

Hello Again and sorry, but my needs change again, now I had to go on Kodi and with kodi all my anime has to exchange name and numbering

actualy with the script below i have this:

Source File:
Boku No Hero Academia S3 01.mkv
Darling In The Franxx 01.mkv

Into
Boku No Hero Academia\Boku No Hero Academia S3\Boku No Hero Academia S3 01.mkv
Darling In The Franxx\Darling In The Franxx 01.mkv
var
  Parts: TWideStringArray;

begin
  Parts := SubMatchesRegEx(FileName, '(.+)\s+(S\d+)(\s+\d+\..+)', FALSE);
  if Length(Parts) > 0 then
  begin
    FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1]+'\'+Parts[0]+' '+Parts[1]+Parts[2];
    Exit;
  end;

  Parts := SubMatchesRegEx(FileName, '(.+)\s+(\d+\..+)', FALSE);
  if Length(Parts) > 0 then
  begin
    FileName := Parts[0]+'\'+Parts[0]+' '+Parts[1];
    Exit;
  end;
end.

now what i need:

Source File:
Boku No Hero Academia S3 01.mkv
Ginga Eiyuu Densetsu Die Neue These Seiran S0 01.mkv
Fire Force S01E01.mkv
Fire Force s01e12.mkv
Darling In The Franxx 01.mkv*

To
Boku No Hero Academia\Boku No Hero Academia S3\Boku No Hero Academia S3E01.mkv
Ginga Eiyuu Densetsu Die Neue These Seiran\Ginga Eiyuu Densetsu Die Neue These Seiran S0\Ginga Eiyuu Densetsu Die Neue These SeiranS0E01.mkv
Fire Force\Fire Force\Fire Force S1E01.mkv
Fire Force\Fire Force\Fire Force S1E12.mkv
Darling In The Franxx\Darling In The Franxx S1\Darling In The Franxx S1E01.mkv*

*Is it possible to if there is no "S1" from it automatically creates like "Darling In The Franxx" example, but if there is S2, S3 etc... Do not touch it.

I hope to have been clear?

Thanks for advance.
Best regards.

Last edited by erebus (2019-11-09 07:22)

Offline

#10 2019-11-09 12:34

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Create Folder & Subfolder according filename

Hi erebus,

Try these two RegExes:

1) Regular Expressions: Replace expression "(.+) [Ss]0?(\d)\s?[Ee]?(\d+)" with "$1\\$1 S$2\\$1 S$2E$3" (skip extension)
2) Regular Expressions: Replace expression "((.+) (\d+))" with "$2\\$2 S1\\$2 S1E$3" (skip extension)

First RegEx will match the first six examples, and the second one last example.

Note: I presume that space is omitted accidentally in the second expected example, so it is added as a result, as well as "S1" in 3rd and 4th example in the second path.

Source File:

Boku No Hero Academia S3 01.mkv
Ginga Eiyuu Densetsu Die Neue These Seiran S0 01.mkv
Fire Force S01E01.mkv
Fire Force s01e12.mkv
Darling In The Franxx S201.mkv
Darling In The Franxx S0310.mkv
Darling In The Franxx 01.mkv

To:

Boku No Hero Academia\Boku No Hero Academia S3\Boku No Hero Academia S3E01.mkv
Ginga Eiyuu Densetsu Die Neue These Seiran\Ginga Eiyuu Densetsu Die Neue These Seiran S0\Ginga Eiyuu Densetsu Die Neue These Seiran S0E01.mkv
Fire Force\Fire Force S1\Fire Force S1E01.mkv
Fire Force\Fire Force S1\Fire Force S1E12.mkv
Darling In The Franxx\Darling In The Franxx S2\Darling In The Franxx S2E01.mkv
Darling In The Franxx\Darling In The Franxx S3\Darling In The Franxx S3E10.mkv
Darling In The Franxx\Darling In The Franxx S1\Darling In The Franxx S1E01.mkv

Is this worked for you?


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

Board footer

Powered by FluxBB