Jump to content
Ketarin forum

TIP : Ketarin variable equivalents in Powershell


Ambimind
 Share

Recommended Posts

Ketarin variables and their equivalents:

The variables are placed into four groups according to essential character.

Ketarin               Powershell
--------              ------------

[Native]   
{filesize}            $app.LastFileSize
{category}            $app.Category
{appname}             $app.Name or $app
{appguid}             $app.Guid
{file}                [$file =] $app.CurrentLocation

   
[Derived : refer to {file}]
{url:ext}             (Get-Item $file).Extension
{url:basefile}        (Get-Item $file).Basename (result: ccleaner)
{root}                split-path $file -Qualifier (result: C:)
                      (PWD).drive.root (result: C:\)
Job/App dir           (Get-Item $file).DirectoryName (no trailing \)
File.Ext              (Get-Item $file).Name
{startuppath}         PWD (assumes no prior CD) (no trailing \)
   

[Job specific user defined variables]
{"myvar"}             $app.variables."myvar".CachedContent
                      $app.variables."myvar".TextualContent
   

[User-defined global variables]
{"myglobalvar"}       $globalvars."myglobalvar".CachedContent
 

How to make their use more convenient ?

The native Ketarin syntax is very convenient. To assist in making the Powershell equivalents more so, you may do the following. At the beginning of each cammand input insert a predefined, saved snippet that looks something like this:

$file   = $app.CurrentLocation
$fdir   = (Get-Item $file).DirectoryName
$fnm    = (Get-Item $file).Basename
$fext   = (Get-Item $file).Extension
$fnmext = (Get-Item $file).Name
$kroot  = PWD

How do you know this without official documentation ?

From within a Ketarin command input, set to "Powershell script", and type:

$app | Select-Object * | Out-File c:\app.txt -width 400
$globalvars | Select-Object * | Out-File c:\globalvars.txt -width 400

Repeat whenever you encounter a property which refers to a sub-object, ie. {.....}.

Also, don't forget "Get-Member" and "Get-Member -Force".

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.