Jump to content
Ketarin forum
Ambimind

TIP : Ketarin variable equivalents in Powershell

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".

Share this post


Link to post
Share on other sites

version is a constructed variable for applications based on FileHippo and a manual variable for other applications. the same methods work to identify the available variables.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • 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.