Author Topic: Rename profiles accessed by MS?  (Read 21788 times)

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 511
    • View Profile
Rename profiles accessed by MS?
« on: December 24, 2016, 16:27:43 »
I see that it is possible to use filters in MS now & maybe dreamed this also applied to rename profiles..?
So far I cannot find anything related to MS calling rename filters though.
Perhaps it is a 'to do'?
If not please point me in the right direction! ;)

Meanwhile I will have to do it the old way,   ;D

Merry Xmas

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 511
    • View Profile
Re: Rename profiles accessed by MS?
« Reply #1 on: December 25, 2016, 11:08:19 »
Thought I'd share my 'solution'.  I expect the MS wizards will know a better/optimal way, but this works for me on one or multiple files to clean up/replace  unwanted chars in filenames. ;)

Code: [Select]
//Name cleanup

@var $arr1 = GetSourceSelectedPaths();
@var $items = arrayCount($arr1);
@var $CurrentNameFullPath;
@var $OrgName;
@var $NewName0;
@var $NewName1;
@var $NewName2;
@var $NewName3;
@var $NewName4;
@var $NewName5;
@var $n1;

for( $n1 = 0; $n1 < $items; $n1++ )
{
  $CurrentNameFullPath = $arr1[ $n1 ];
  $OrgName = PathGetNamePart( $CurrentNameFullPath );
  $NewName0 = StrReplace( $OrgName, "_ " , "-" );
  $NewName1 = StrReplace( $NewName0, " m" , " e " );
  $NewName2 = StrReplace( $NewName1, " r" , "R" );
  $NewName3 = StrReplace( $NewName2, " y" , " " );
  $NewName4 = StrReplace( $NewName3, " x" , "m" );
  $NewName5 = StrReplace( $NewName4, "a" , " s" );
 
  RenameFile( $CurrentNameFullPath, $NewName5, "SILENT" );
}

« Last Edit: December 25, 2016, 12:13:20 by Ulfhednar »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4407
    • View Profile
    • Multi Commander
Re: Rename profiles accessed by MS?
« Reply #2 on: December 27, 2016, 13:05:24 »
I see that it is possible to use filters in MS now & maybe dreamed this also applied to rename profiles..?
So far I cannot find anything related to MS calling rename filters though.
Perhaps it is a 'to do'?
If not please point me in the right direction! ;)

Meanwhile I will have to do it the old way,   ;D

Merry Xmas
Filters is not new in the release ?
Not sure I get what you want to do ?

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4407
    • View Profile
    • Multi Commander
Re: Rename profiles accessed by MS?
« Reply #3 on: December 27, 2016, 13:08:03 »
Thought I'd share my 'solution'.  I expect the MS wizards will know a better/optimal way, but this works for me on one or multiple files to clean up/replace  unwanted chars in filenames. ;)

Code: [Select]
//Name cleanup

@var $arr1 = GetSourceSelectedPaths();
@var $items = arrayCount($arr1);
@var $CurrentNameFullPath;
@var $OrgName;
@var $NewName0;
@var $NewName1;
@var $NewName2;
@var $NewName3;
@var $NewName4;
@var $NewName5;
@var $n1;

for( $n1 = 0; $n1 < $items; $n1++ )
{
  $CurrentNameFullPath = $arr1[ $n1 ];
  $OrgName = PathGetNamePart( $CurrentNameFullPath );
  $NewName0 = StrReplace( $OrgName, "_ " , "-" );
  $NewName1 = StrReplace( $NewName0, " m" , " e " );
  $NewName2 = StrReplace( $NewName1, " r" , "R" );
  $NewName3 = StrReplace( $NewName2, " y" , " " );
  $NewName4 = StrReplace( $NewName3, " x" , "m" );
  $NewName5 = StrReplace( $NewName4, "a" , " s" );
 
  RenameFile( $CurrentNameFullPath, $NewName5, "SILENT" );
}

(Why do use NewName1 -> 5, ?? why not use the same variable ?? )

In the MultiRename tool you can replace char x with y and so on in the search and replace part

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 511
    • View Profile
Re: Rename profiles accessed by MS?
« Reply #4 on: December 28, 2016, 10:15:51 »
Sorry to ruin your Xmas break Mathias!  :o

Originally I wanted to call an existing rename profile (in the same way as a filter) with a MScript.  Couldn't see how to do that.  Filters have an ID to call but I have not found ID tags in the rename dialog & didn't dig deeper. 

Not all files contain all the same items I want to change.  Some have one character to change, others some or all.
I wasn't sure I could apply a single @var to this task.  I expected conflicts.
I concluded that with multiple possible case-sensitive rename actions, I needed to queue them discretely, so gave them different @vars.   
Would a Function concatenate multiple changes...?

As you know I like to cause headaches with MultiScript - I find it therapeutic.   8) :)
« Last Edit: December 28, 2016, 14:08:21 by Ulfhednar »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4407
    • View Profile
    • Multi Commander
Re: Rename profiles accessed by MS?
« Reply #5 on: December 29, 2016, 14:05:43 »
Sorry to ruin your Xmas break Mathias!  :o

Originally I wanted to call an existing rename profile (in the same way as a filter) with a MScript.  Couldn't see how to do that.  Filters have an ID to call but I have not found ID tags in the rename dialog & didn't dig deeper. 

Not all files contain all the same items I want to change.  Some have one character to change, others some or all.
I wasn't sure I could apply a single @var to this task.  I expected conflicts.
I concluded that with multiple possible case-sensitive rename actions, I needed to queue them discretely, so gave them different @vars.   
Would a Function concatenate multiple changes...?

As you know I like to cause headaches with MultiScript - I find it therapeutic.   8) :)

I added two new strReplace  MultiScript function in 6.9.1, so doing the thing about or similar should be easier.

Code: [Select]
// Replace every 'a' and every b and c with the substring "Dragon" 
// so if $name is  "abcdef" it will be  "555def"  the replace with can be a substring with many chars. BUT is you include characters there are inlcuded in the replace characters , The result will be strange
$Name = StrReplaceChars( $Name, "abc" , "5" ); 

// This require that Replace pattern and ReplaceWith is the same lenght, the first char in 'replace' will be replaced with the first char in "replacewith" and so on.
$Name = StrReplaceCharsPairs( $Name, "_ mryxa" , "-eR ms" );

Ulfhednar

  • Contributor
  • VIP Member
  • *****
  • Posts: 511
    • View Profile
Re: Rename profiles accessed by MS?
« Reply #6 on: December 30, 2016, 13:23:22 »
Thanks Mathias!  :D
New Toys! It's like it's Xmas!  ...oh wait... :P

I will have some fun with these new commands.   8)

AlanJB

  • VIP Member
  • *****
  • Posts: 433
  • VERY old Programmer
    • View Profile
Re: Rename profiles accessed by MS?
« Reply #7 on: January 03, 2017, 18:47:08 »
Hi Mathias.

Are there plans to add  StrReplaceChars() and StrReplaceCharsPairs() to the documentation?

If so, I feel some editing coming on ;)

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4407
    • View Profile
    • Multi Commander
Re: Rename profiles accessed by MS?
« Reply #8 on: January 05, 2017, 11:12:30 »
Hi Mathias.

Are there plans to add  StrReplaceChars() and StrReplaceCharsPairs() to the documentation?

If so, I feel some editing coming on ;)
Hehe yes.. I just forgot about that..