#11 2019-08-23 12:43

exploid
Member
Registered: 2019-08-23
Posts: 14

Re: Search an Specific syntax in Name and use this to Rename

can the Problem be that it isnt in an while loop?

Offline

#12 2019-08-23 13:09

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

Re: Search an Specific syntax in Name and use this to Rename

Have you tried it with a simple set of Insert and Replace rules as described in a previous post?

Offline

#13 2019-08-23 13:13

exploid
Member
Registered: 2019-08-23
Posts: 14

Re: Search an Specific syntax in Name and use this to Rename

i found the error it was ;

old Code

// Bedingung .3dm
    if vExt = '.3dm' then
      begin
		  // split the filename into parts by utilizing regular expressions:
		  // SubMatchesRegEx(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray;
		   REMatches:=SubMatchesRegEx(FileName,'(.+)(_AZ_)(.+)',true);
		   if Length(REMatches) <= 0 then
				//no match, no _AZ_ found then
     		  FileName := FileName + '_NSM' + vExt;
       else
		 FileName := FileName + '_AZ' + vExt;
    end;
// Bedingung .3dm 

working Code

// Bedingung .3dm
    if vExt = '.3dm' then
      begin
		  // split the filename into parts by utilizing regular expressions:
		  // SubMatchesRegEx(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray;
		   REMatches:=SubMatchesRegEx(FileName,'(.+)(_AZ_)(.+)',true);
		   if Length(REMatches) <= 0 then
				//no match, no _AZ_ found then
     		  FileName := FileName + '_NSM' + vExt
       else
				  FileName := FileName + '_AZ' + vExt
    end;
// Bedingung .3dm 

The Compiler didnt Crashs anymore but the Filtering isnt work .3dm with _AZ_ in his name is still named as _NSM

Last edited by exploid (2019-08-23 13:18)

Offline

#14 2019-08-23 14:22

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

Re: Search an Specific syntax in Name and use this to Rename

Ah, I see. (copy&paste error)
There should be only one semicolon, the one at the end.


                FileName := FileName + '_NSM' + vExt
            else
                FileName := FileName + '_AZ' + vExt; 




EDIT:
Oh, I am too late, you already god it.

@den4b
He need this as part of a bigger code, see his code block at the first page.




 

Last edited by Stefan (2019-08-23 14:24)


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

#15 2019-08-23 16:31

exploid
Member
Registered: 2019-08-23
Posts: 14

Re: Search an Specific syntax in Name and use this to Rename

No Problem smile
but it looks like REMatches gives no Result so the algorythmus dosnt work to check the files so its many files to check i change with this script like 200 or 300 items.
Checks this system with regex each file or all files and name all as _AZ if one will be found?

i let the Script give me an Output from REMatches the result is Fehler: Type mismatch

Last edited by exploid (2019-08-23 16:45)

Offline

#16 2019-08-23 16:59

exploid
Member
Registered: 2019-08-23
Posts: 14

Re: Search an Specific syntax in Name and use this to Rename

i Got it

var
  vExt: WideString;
  REMatches: TWideStringArray;
  BaseName: WideString;

// Dateiendung Filtern
  vExt     := WideExtractFileExt(FilePath);
  BaseName := WideExtractBaseName(FilePath);  
// Dateiendung Filtern 


// Bedingung .3dm
    if vExt = '.3dm' then
      begin
		  // split the filename into parts by utilizing regular expressions:
		  // SubMatchesRegEx(const Input, Find: WideString; const CaseSensitive: Boolean): TWideStringArray;
		   REMatches:=SubMatchesRegEx(BaseName,'(.+)(_AZ_)(.+)',true);
		   if (Length(REMatches) <= 0) then
				//no match, no _AZ_ found
        FileName := FileName + '_NSM' + vExt
			else
	FileName := FileName + '_AZ' + vExt;
    end;
// Bedingung .3dm    

i used now BaseName and the change to your code is that i dont pick the FileName i pick the FilePath to the file, after that it works fine thanks for your Great help.

Schöne Grüße vom Saarland wink

Last edited by exploid (2019-08-23 17:02)

Offline

Board footer

Powered by FluxBB