Page 1 of 1

How to omit preview with #126; in a script?

Posted: 10 Sep 2011 21:02
by Jerry
Hi all,
I have a script that does several transformations for normalizing file names, one of which is to run the capitalization command #126;. In this case, however, I do not want the preview popup and don't want to be informed about whether only some or none of the names are actually changed. I don't want to have to otherwise first change a related global configuration option to turn off the preview. I see that there is a preview parameter to the rename function, but I don't see a way to use the "Aaa Aa.*" pattern with that function. I also didn't see an alternative scripting function for doing the 126; command.

So how can I omit the preview with #126; when used in a script?

Re: How to omit preview with #126; in a script?

Posted: 12 Sep 2011 12:58
by TheQwerty
Currently this is the only way to achieve this accurately:

Code: Select all

"126 without Previews"
  #193; //File | Settings | Save Configuration
  $PreviewRenameSpecial = GetKey('PreviewRenameSpecial', 'Settings'); //Reads the current state of Preview All from xyplorer.ini.
  if ($PreviewRenameSpecial == 1) {
    //Disable Previews
    #148; //File | Rename Special | Preview All
  }
  #126; //File | Rename Special | Aaa Aa.*
  if ($PreviewRenameSpecial == 1) {
    //Enable Previews
    #148; //File | Rename Special | Preview All
  }
As you can see this method requires saving the configuration (just xyplorer.ini) - as that's the only way to get the current state of the Preview All setting.

If you never toggle Preview All you could shorten this to just:

Code: Select all

"126 without Previews"
  //Disable Previews
  #148; //File | Rename Special | Preview All
  #126; //File | Rename Special | Aaa Aa.*
  //Enable Previews
  #148; //File | Rename Special | Preview All
However, this depends on the script always starting from that known state.

Re: How to omit preview with #126; in a script?

Posted: 12 Sep 2011 16:21
by Jerry
Ok, I guess that will have to do, though it is cumbersome. I think Don ought to add a function for doing this kind of rename with the appropriate options. Thanks.

Re: How to omit preview with #126; in a script?

Posted: 12 Sep 2011 17:14
by TheQwerty
It's possible to achieve the same results (I believe) without using #126, but it involves looping through all of the selected items and using recase followed by renameItem on each:

Code: Select all

"Similar to #126..."
  $items = Report("{Basename}|{Fullname}<crlf>", 1);
  foreach ($token, "$items", "<crlf>") {
    if ("$token" UnLike '') {
      $base = GetToken("$token", 1, '|');
      $item = GetToken("$token", 2, '|');

      $base = Recase("$base", 'Title');
      RenameItem("$base", "$item");
    }
  }

Re: How to omit preview with #126; in a script?

Posted: 12 Sep 2011 17:33
by Jerry
TheQwerty wrote:It's possible to achieve the same results (I believe) without using #126, but it involves looping through all of the selected items and using recase followed by renameItem on each:
Hmm.. Actually, I think I'll adapt your bit of script because ideally, when I do these case renames, I prefer words like "the", "and", "of", "a" etc. to not be capitalized. So I could achieve that with the addition of an inner loop where each each word in $base is selectively recased.