#1 2017-10-08 11:05

Elektro
Senior Member
Registered: 2014-05-28
Posts: 72

Preset file doesn't update a modified rule when loading it in Renamer

Scenario:

To automate the renaming of many directories, I built an application that basically what it does is iterate those folders to pick a specific part of the folder name and insert it in a Renamer's preset.

To understand it better, I have a template preset that has this rule inside:

[Rule3]
ID=Replace
Config=TEXTWHAT:%23Artist%23;TEXTWITH:%5BPut+Artist+Here%5D;WHICH:1;SKIPEXTENSION:1;CASESENSITIVE:0;USEWILDCARDS:0;WHOLEWORDSONLY:0
Marked=1

Then in my application I change the value of the TEXTWITH field, like for example:

[Rule3]
ID=Replace
Config=TEXTWHAT:%23Artist%23;TEXTWITH:A+Balance+Between;HICH:1;SKIPEXTENSION:1;CASESENSITIVE:0;USEWILDCARDS:0;WHOLEWORDSONLY:0
Marked=1

And finally I save this modified preset in a temporary file.

When I run Renamer.exe via command-line to load that modified preset file, the field that I modified is not updated in the preview listview:

PO1gTfP.png
( The same problem happens when I run Renamer.exe as normally, not from the command-line, and I load the modified preset file. )

So, in order to make this modified rule work, I need to press the "Save Rule" button here:

UAVjVjM.png

And then the rule is properly updated in the preview listview:

BsT3QA3.png

My question is: why the rule is not automatically updated when I load the modified preset?. what exactly does the "Save Rule" button ir order to update the rule?, because I tried to monitorize it to try automate the procedure but it seems that none file modification is made when I press the "Save Rule" button...

This is the full modified preset file content that I tried to load:

[Rule0]
ID=RegEx
Config=EXPRESSION:%28%5E%28%5Cs%2B%29%3F%5Cd%2B%28%5Cs%2B%29%3F%5B%2D%5C%2E%5D%29%7B1%7D%7C%28%5E%28%5Cs%2B%29%3F%5Cd%2B%5B%2D%5F%5Cs%5D%2B%29%7B1%7D%7C%28%5E%28%5Cs%2B%29%3F%5BA%2DD%5D%7B1%7D%28%5B0%2D9%5D%7B1%7D%29%5Cs%2B%3F%29%7B1%7D;REPLACE:;CASESENSITIVE:0;SKIPEXTENSION:1
Marked=1

[Rule1]
ID=CleanUp
Config=BRACKETSROUND:0;BRACKETSSQUARE:0;BRACKETSCURVY:0;SPACESDOT:0;SPACESCOMMA:0;SPACESUNDERSCORE:1;SPACESPLUS:0;SPACESHYPHEN:0;SPACESWEB:1;SPACESSKIPVERSIONS:0;SPACESFIX:1;SKIPEXTENSION:1;PREPAREFORSHAREPOINT:0;INSERTSPACEBEFORECAPITALS:0;NORMALIZESPACES:1
Marked=1

[Rule2]
ID=Insert
Config=TEXT:%23Artist%23+%2D+;WHERE:1;POSITION:1;INSERTAFTERTEXT:;INSERTBEFORETEXT:;RIGHTTOLEFT:0;SKIPEXTENSION:1
Marked=1

[Rule3]
ID=Replace
Config=TEXTWHAT:%23Artist%23;TEXTWITH:A+Balance+Between;HICH:1;SKIPEXTENSION:1;CASESENSITIVE:0;USEWILDCARDS:0;WHOLEWORDSONLY:0
Marked=1

[Rule4]
ID=Translit
Config=ALPHABET:%22%3D%27%0D%0A%2523%3D%23%0D%0A%2524%3D%24%0D%0A%2525%3D%25%0D%0A%2526%3D%26%0D%0A%2527%3D%27%0D%0A%2528%3D%28%0D%0A%2529%3D%29%0D%0A%253B%3D%3B%0D%0A%255B%3D%5B%0D%0A%255D%3D%5D%0D%0A%26%238217%3D%27%0D%0A%26amp%3B%3D%26%0D%0A%26plusmn%3B%3D%2B%0D%0A%27remix%3DRemix%0D%0A%27rmx%3DRemix%0D%0A%28%28%3D%28%0D%0A%28Demo+Mix%29%3D%28Demo+Version%29%0D%0A%28Demo%29%3D%28Demo+Version%29%0D%0A%28Dub%29+%3D+%28Dub+Mix%29%0D%0A%28Extended%29%3D%28Extended+Mix%29%0D%0A%28Instrumental%29%3D%28Instrumental+Mix%29%0D%0A%28Radio%29%3D%28Radio+Mix%29%0D%0A%28Vocal%29%3D%28Vocal+Mix%29%0D%0A%29%29%3D%29%0D%0A%2B%C2%A1%3D%C3%AD%0D%0A%2B%C2%A6%3D%C3%B1%0D%0A%2B%C3%AD%3D%C3%A1%0D%0AD%2EJ%2E%3DDj%0D%0AD%2EJ%3DDj%0D%0ADJ%2E%3DDj%0D%0A+I+M+%3D+I%27m+%0D%0AMash+%2D+up%3DMashup%0D%0AMash+up%3DMashup%0D%0AMash%2Dup%3DMashup%0D%0An%E2%95%A0%C3%82%3D%C3%B1%0D%0ARemix+Version%3DRemix%0D%0ARmx%3DRemix%0D%0AS%3Ds%0D%0Au%CC%88%3Du%0D%0A%7B%3D%28%0D%0A%7D%3D%29%0D%0A%7E%3D%0D%0A%C2%A1%3D%0D%0A%C2%BF%3D%0D%0A%C3%AA%3De%0D%0A%C3%B0%C2%A2%3D%C3%AD%0D%0A%C3%94%C3%87%C2%AA%3D%2E%2E%2E%0D%0A%C3%94%C3%87%C3%B4%3D%2D%0D%0A%C3%94%C3%87%C3%96%3D%27%0D%0A%C3%96%3Do%0D%0A%C5%9B%3Ds%0D%0A%D0%A1%3Dc%0D%0A%E2%80%93%3D%2D%0D%0A%E2%80%99%3D%27%0D%0A%E2%94%9C%C2%A1%3D%C3%AD%0D%0A%E2%94%9C%C2%A9%3Do%0D%0A%E2%94%9C%C2%AE%3D%C3%A9%0D%0A%E2%94%9C%C2%BD%3De%0D%0A%E2%94%9C%C2%BF%3D%C3%A8%0D%0A%E2%94%9C%C3%AD%3D%C3%A1%0D%0A%E2%94%9C%C3%9C%3D%C3%81%0D%0A%E2%94%9C%E2%94%82%3D%C3%B3%0D%0A%E2%94%9C%E2%95%91%3D%C3%BA%0D%0A%E2%94%9C%E2%96%92%3D%C3%B1%0D%0A%E2%94%AC%C3%AD%3D%C2%A1%0D%0A%E2%94%AC%E2%94%A4%3D%27%0D%0A+%2D+Web+%2D+2014%3D%0D%0A+%40+%3D+at+%0D%0A+ain+t+%3D+Ain%27t+%0D%0A+aint+%3D+Ain%27t+%0D%0A+and+%3D+%26+%0D%0A+can+t+%3D+Can%27t+%0D%0A+cant+%3D+Can%27t+%0D%0A+comin+%3D+Comin%27+%0D%0A+Corazon+%3D+Coraz%C3%B3n+%0D%0A+dancin+%3D+Dancin%27+%0D%0A+didnt+%3D+Didn%27t+%0D%0A+didn+t+%3D+Didn%27t+%0D%0A+djs+%3D+Dj%27s+%0D%0A+dj+s+%3D+Dj%27s+%0D%0A+don+t+%3D+Don%27t+%0D%0A+dont+%3D+Don%27t+%0D%0A+Dr+%3D+Dr%2E+%0D%0A+flyin+%3D+Flyin%27+%0D%0A+i+ll+%3D+I%27ll+%0D%0A+i+m+%3D+I%27m+%0D%0A+i+ve+%3D+I%27ve+%0D%0A+ill+%3D+I%27ll+%0D%0A+im+%3D+I%27m+%0D%0A+it+s+%3D+It%27s+%0D%0A+its+%3D+It%27s+%0D%0A+ive+%3D+I%27ve+%0D%0A+let+s+%3D+Let%27s+%0D%0A+lets+%3D+Let%27s+%0D%0A+that+s+%3D+That%27s+%0D%0A+thats+%3D+That%27s+%0D%0A+versus+%3D+Vs%2E+%0D%0A+vs+%3D+Vs%2E+%0D%0A+walkin+%3D+Walkin%27+%0D%0A+won+t+%3D+Won%27t+%0D%0A+wont+%3D+Won%27t+%0D%0A+you+ll+%3D+You%27ll+%0D%0A+you+re+%3D+You%27re+%0D%0A+youll+%3D+You%27ll+%0D%0A+youre+%3D+You%27re+;DIRECTION:1;SKIPEXTENSION:1
Marked=1

[Rule5]
ID=PascalScript
Config=SOURCEUTF8:%2F%2F+Formats+an+audio+filename+that+has+the+%22%2E%2E%2Efeaturing+artist%22+part+at+the+end+of+filename%2E%0D%0A%2F%2F%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%2D%0D%0A%0D%0A%0D%0A%2F%2F+Pseudo%2DExample%3A%0D%0A%2F%2F%0D%0A%2F%2F+From%3A+%5B0%5DARTIST%5FNAME++%5B1%5DDASH++%5B2%5DTRACK%5FTITLE++%5B3%5DFEAT%5FARTIST++%5B4%5DPOSSIBLE%5FADDITIONAL%5FINFO%5FINSIDE%3A%28%29%5B%5D%7B%7D%0D%0A%2F%2F+To%3A+++%5B0%5DARTIST%5FNAME++%5B3%5DFEAT%5FARTIST++%5B1%5DDASH++%5B2%5DTRACK%5FTITLE++%5B4%5DPOSSIBLE%5FADDITIONAL%5FINFO%5FINSIDE%3A%28%29%5B%5D%7B%7D%0D%0A%0D%0A%2F%2F+Real%2DExample%3A%0D%0A%2F%2F%0D%0A%2F%2F+From%3A+Carbin+%26+Sirmark+%2D+Sorry+Feat%2E+Sevener%2Emp3%0D%0A%2F%2F+To%3A+++Carbin+%26+Sirmark+Feat%2E+Sevener+%2D+Sorry%2Emp3%0D%0A%0D%0A%2F%2F+Known+limitations%3A%0D%0A%2F%2F%0D%0A%2F%2F+%E2%80%A2+If+%5B0%5DARTIST%5FNAME+or+%5B2%5DTRACK%5FTITLE+parts+contains+any+%22+%2D+%22+the+script+will+exclude+the+replacement+for+safety%2E%0D%0A%2F%2F+++That+is%2C+the+script+prevents+any+replacement+on+that+sort+of+filenames%2C+so+don%27t+worry%2E%0D%0A%0D%0A%0D%0Avar%0D%0A++rgxPattern%3A+String%3B%0D%0A++rgxReplace%3A+String%3B%0D%0A++dashCount%3A+Integer%3B%0D%0A++containsFeat%3A+Boolean%3B%0D%0A++baseName%3A+String%3B%0D%0A++extension%3A+WideString%3B%0D%0A++regexconOutput%3A+String%3B%0D%0A%0D%0Abegin%0D%0A%0D%0A++baseName++%3A%3D+WideExtractBaseName%28FileName%29%0D%0A++extension+%3A%3D+WideExtractFileExt%28FileName%29%3B%0D%0A%0D%0A++%2F%2F+The+regular+expression+that+matches+the+filename+parts%2E%0D%0A++%2F%2F+http%3A%2F%2Fstackoverflow%2Ecom%2Fquestions%2F32807698%2Fregex%2Dpattern%2Dto%2Dlimit%2Ddashes%2Din%2Dthese%2Dcircumstances%0D%0A++rgxPattern+%3A%3D+%27%5E%28%3F%3Cartist%3E%2E%2B%3F%28%3F%3D%5Cs%2A%2D%5Cs%2A%29%29%5Cs%2A%2D%5Cs%2A%28%3F%3Ctitle%3E%2E%2B%3F%28%3F%3D%28%3F%3A%5C%28%3F%5B%5Cs%5C%28%5C%5B%5C%7B%29%5D%28ft%7Cfeat%7Cfeaturing%29%5B%5Cs%5C%2E%5D%29%7C%24%29%29%5B%5Cs%5C%28%5C%5B%5C%7B%29%5D%3F%28%3F%3Cfeat%3E%28ft%7Cfeat%7Cfeaturing%29%5B%5Cs%5C%2E%5D%5B%5E%5C%28%5C%29%5Cn%5D%2B%29%3F%5C%29%3F%28%3F%3Csubtitle%3E%2E%2B%29%3F%24%27%0D%0A++rgxReplace+%3A%3D+%27%24%7Bartist%7D+%24%7Bfeat%7D+%2D+%24%7Btitle%7D+%24%7Bsubtitle%7D%27%0D%0A%0D%0A++%2F%2F+The+amount+of+%22%2D%22+that+contains+the+filename%2E%0D%0A++dashCount++++%3A%3D+high%28MatchesRegEx%28baseName%2C+%27%5Cs%2D%5Cs%27+%2C+false%29%29%3B%0D%0A++containsFeat+%3A%3D+IsMatchingRegEx%28baseName%2C+%27%5B%5Cs%5C%28%5C%5B%5C%7B%29%5D%28ft%7Cfeat%7Cfeaturing%29%5B%5Cs%5C%2E%5D%27%2C+false%29%3B%0D%0A%0D%0A++%2F%2F+If+only+one+%22%2D%22+is+found+then%2E%2E%2E%0D%0A++If+%28dashCount+%3D+0%29+Then%0D%0A++%2F%2F+If+%22ft%22+or+%22feat%22+or+%22featuring%22+is+found+then%2E%2E%2E%0D%0A++++If+%28containsFeat%29+Then%0D%0A++++++begin+%2F%2F+Do+the+replacement%2E%0D%0A++++++++if+ExecConsoleApp%28%27%22%27%2B+WideExtractFileDir%28GetApplicationPath%28%29%29+%2B+%27%5CTools%5CRegexCon%2Eexe%27+%2B%0D%0A++++++++++++++++++++++++++%27%22+%2FInput%3D%22%27+%2B+baseName+%2B%0D%0A++++++++++++++++++++++++++%27%22+%2FExpression%3D%22%27+%2B+rgxPattern+%2B%0D%0A++++++++++++++++++++++++++%27%22+%2FSubstitution%3D%22%27+%2B+rgxReplace+%2B%0D%0A++++++++++++++++++++++++++%27%22+%2FMatchCase%3DFalse%27%2C+regexconOutput%29+%3D+0+then%0D%0A++++++++FileName+%3A%3D+regexconOutput+%2B+extension%3B%0D%0A++++++end%3B%0D%0A%0D%0Aend%2E%0D%0A
Marked=1

[Rule6]
ID=RegEx
Config=EXPRESSION:%5C%28Original+%28Mix%7CVersion%29%5C%29;REPLACE:;CASESENSITIVE:0;SKIPEXTENSION:1
Marked=1

[Rule7]
ID=RegEx
Config=EXPRESSION:%5C%28%28Bonus%7CHidden%29+Track%5C%29;REPLACE:;CASESENSITIVE:0;SKIPEXTENSION:1
Marked=1

[Rule8]
ID=RegEx
Config=EXPRESSION:%5CA%28%5B%5E%5C%2D%5D%2A%3F%29%5Cs%2A%5C%2D%5Cs%2A%28%2E%2A%3F%29%5Cs%2A%5B%5C%28%5C%5B%5D%28%28ft%5B%5C%2E%5Cs%5D%7Cfeat%5B%5C%2E%5Cs%5D%7Cfeaturing%5B%5C%2E%5Cs%5D%29%5B%5E%5C%29%5D%2A%29%5B%5C%29%5C%5D%5D%28%2E%2B%29%3F%5CZ;REPLACE:%241+%243+%2D+%242%245;CASESENSITIVE:0;SKIPEXTENSION:1
Marked=1

[Rule9]
ID=RegEx
Config=EXPRESSION:+ft%5C%2E%3F+%7C+feat%5C%2E%3F+%7C+featuring+;REPLACE:+Feat%2E+;CASESENSITIVE:0;SKIPEXTENSION:1
Marked=1

[Rule10]
ID=RegEx
Config=EXPRESSION:%5C%28featuring+%2E%2B%5C%29%7C+%5C%28feat%28%5C%2E%29%3F+%2E%2B%5C%29%7C%5C%28ft%28%5C%2E%29%3F+%2E%2B%5C%29%7C;REPLACE:;CASESENSITIVE:0;SKIPEXTENSION:1
Marked=1

[Rule11]
ID=CleanUp
Config=BRACKETSROUND:0;BRACKETSSQUARE:0;BRACKETSCURVY:0;SPACESDOT:0;SPACESCOMMA:0;SPACESUNDERSCORE:0;SPACESPLUS:0;SPACESHYPHEN:0;SPACESWEB:0;SPACESSKIPVERSIONS:0;SPACESFIX:1;SKIPEXTENSION:1;PREPAREFORSHAREPOINT:0;INSERTSPACEBEFORECAPITALS:0;NORMALIZESPACES:0
Marked=1

[Rule12]
ID=Case
Config=WHAT:3;SKIPEXTENSION:1;EXTENSIONALWAYSLOWERCASE:1;EXTENSIONALWAYSUPPERCASE:0;FORCECASE:0;FRAGMENTSTEXT:
Marked=1

[Filters]
AddFilesFromFolders=1
AddFoldersAsFiles=0
IncludeSubfolders=1
IncludeHidden=0
IncludeSystem=0
SkipRootFoldersAsFiles=0
MasksOnFileName=1
Masks=
MasksExclude=

Last edited by Elektro (2017-10-08 11:16)

Offline

#2 2017-10-08 11:27

Elektro
Senior Member
Registered: 2014-05-28
Posts: 72

Re: Preset file doesn't update a modified rule when loading it in Renamer

Sorry it is solved. It was a very silly issue, a syntax error, just that. I accidentaly was removing the "W" letter of the "WHICH" field when replacing the text in the modified rule.

Elektro wrote:
Config=TEXTWHAT:%23Artist%23;TEXTWITH:A+Balance+Between;HICH:1;SKIPEXTENSION:1;CASESENSITIVE:0;USEWILDCARDS:0;WHOLEWORDSONLY:0

Notice there is written  "HICH:1" instead of "WHICH:1".

Now it works perfect after I fixed the missing "W".

Thanks for read!.

PS: A good thing to say about Renamer is that even a rule with "bad syntax" it can parse/recognize the other fields of the rule. Too good. However a little confuse too, since Renamer does not advertise about a syntax error when parsing the rule...

Last edited by Elektro (2017-10-08 11:30)

Offline

#3 2017-10-08 19:44

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 2,511

Re: Preset file doesn't update a modified rule when loading it in Renamer

I'm glad that you have solved it.

The rule configuration loader only accesses parameters that it needs and any extra parameters will be ignored. Also, if a required parameter is missing then a sensible default value will be used.

This design is geared towards flexibility and ease of upgrading. However, as you have noted, your kind of issue will be silently ignored, unless it brakes the fundamental format.

By the way, if you are programmatically inserting parent folder name, you could use a built-in meta tag File_FolderName.

Last edited by den4b (2017-10-08 19:46)

Offline

Board footer

Powered by FluxBB